Ejemplo n.º 1
0
 /**
  * Add the Add Item form to the theme for display
  */
 public function get_additem_form()
 {
     $additem_form = new FormUI('dash_additem');
     $additem_form->append('select', 'module', 'null:unused');
     $additem_form->module->options = Plugins::filter('dashboard_block_list', array());
     $additem_form->append('submit', 'submit', _t('+'));
     //$form->on_success( array( $this, 'dash_additem' ) );
     $additem_form->properties['onsubmit'] = "dashboard.add(); return false;";
     $this->theme->additem_form = $additem_form->get();
 }
Ejemplo n.º 2
0
 /**
  * Handles POST requests from the options admin page
  */
 public function post_options()
 {
     $option_items = array();
     $timezones = DateTimeZone::listIdentifiers();
     $timezones = array_merge(array('' => ''), array_combine(array_values($timezones), array_values($timezones)));
     $option_items[_t('Name & Tagline')] = array('title' => array('label' => _t('Site Name'), 'type' => 'text', 'helptext' => ''), 'tagline' => array('label' => _t('Site Tagline'), 'type' => 'text', 'helptext' => ''), 'about' => array('label' => _t('About'), 'type' => 'textarea', 'helptext' => ''));
     $option_items[_t('Publishing')] = array('pagination' => array('label' => _t('Items per Page'), 'type' => 'text', 'helptext' => ''), 'atom_entries' => array('label' => _t('Entries to show in Atom feed'), 'type' => 'text', 'helptext' => ''), 'comments_require_id' => array('label' => _t('Require Comment Author Info'), 'type' => 'checkbox', 'helptext' => ''), 'spam_percentage' => array('label' => _t('Comment SPAM Threshold'), 'type' => 'text', 'helptext' => _t('The likelihood a comment is considered SPAM, in percent.')));
     $option_items[_t('Time & Date')] = array('timezone' => array('label' => _t('Time Zone'), 'type' => 'select', 'selectarray' => $timezones, 'helptext' => _t('Current Date Time: %s', array(HabariDateTime::date_create()->format()))), 'dateformat' => array('label' => _t('Date Format'), 'type' => 'text', 'helptext' => _t('Current Date: %s', array(HabariDateTime::date_create()->date))), 'timeformat' => array('label' => _t('Time Format'), 'type' => 'text', 'helptext' => _t('Current Time: %s', array(HabariDateTime::date_create()->time))));
     $option_items[_t('Language')] = array('locale' => array('label' => _t('Locale'), 'type' => 'select', 'selectarray' => array_merge(array('' => 'default'), array_combine(HabariLocale::list_all(), HabariLocale::list_all())), 'helptext' => _t('International language code')), 'system_locale' => array('label' => _t('System Locale'), 'type' => 'text', 'helptext' => _t('The appropriate locale code for your server')));
     $option_items[_t('Troubleshooting')] = array('log_min_severity' => array('label' => _t('Minimum Severity'), 'type' => 'select', 'selectarray' => LogEntry::list_severities(), 'helptext' => _t('Only log entries with a this or higher severity.')), 'log_backtraces' => array('label' => _t('Log Backtraces'), 'type' => 'checkbox', 'helptext' => _t('Logs error backtraces to the log table\'s data column. Can drastically increase log size!')));
     /*$option_items[_t('Presentation')] = array(
     		'encoding' => array(
     			'label' => _t('Encoding'),
     			'type' => 'select',
     			'selectarray' => array(
     				'UTF-8' => 'UTF-8'
     				),
     			'helptext' => '',
     			),
     		);*/
     $option_items = Plugins::filter('admin_option_items', $option_items);
     $form = new FormUI('Admin Options');
     $tab_index = 3;
     foreach ($option_items as $name => $option_fields) {
         $fieldset = $form->append('wrapper', Utils::slugify(_u($name)), $name);
         $fieldset->class = 'container settings';
         $fieldset->append('static', $name, '<h2>' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</h2>');
         foreach ($option_fields as $option_name => $option) {
             $field = $fieldset->append($option['type'], $option_name, $option_name, $option['label']);
             $field->template = 'optionscontrol_' . $option['type'];
             $field->class = 'item clear';
             if ($option['type'] == 'select' && isset($option['selectarray'])) {
                 $field->options = $option['selectarray'];
             }
             $field->tabindex = $tab_index;
             $tab_index++;
             if (isset($option['helptext'])) {
                 $field->helptext = $option['helptext'];
             } else {
                 $field->helptext = '';
             }
         }
     }
     /* @todo: filter for additional options from plugins
      * We could either use existing config forms and simply extract
      * the form controls, or we could create something different
      */
     $submit = $form->append('submit', 'apply', _t('Apply'), 'admincontrol_submit');
     $submit->tabindex = $tab_index;
     $form->on_success(array($this, 'form_options_success'));
     $this->theme->form = $form->get();
     $this->theme->option_names = array_keys($option_items);
     $this->theme->display('options');
 }
Ejemplo n.º 3
0
 public function configure()
 {
     $form = new FormUI('lipsum');
     // $form->set_settings( array( 'use_session_errors' => true ) );
     $form->append(FormControlText::create('num_posts', 'option:lipsum__num_posts')->add_validator('validate_lipsum_numbers')->label(_t('Number of posts to have present:', __CLASS__)));
     $form->append(FormControlText::create('num_comments', 'option:lipsum__num_comments')->add_validator('validate_lipsum_numbers')->label(_t('Max number of comments for each post:', __CLASS__)));
     $form->append(FormControlText::create('num_tags', 'option:lipsum__num_tags')->add_validator('validate_lipsum_numbers')->label(_t('Max number of tags for each post:', __CLASS__)));
     $form->append(FormControlSubmit::create('save')->set_caption('Save'));
     $form->on_success(array($this, 'updated_config'));
     echo $form->get();
 }
Ejemplo n.º 4
0
 /**
  * Implement the simple plugin configuration.
  * @return FormUI The configuration form
  */
 public function configure()
 {
     $form = new FormUI('piwik');
     $form->append('text', 'siteurl', 'option:piwik__siteurl', _t('Piwik site URL', 'piwik'));
     $form->append('text', 'sitenum', 'option:piwik__sitenum', _t('Piwik site number', 'piwik'));
     $form->append('text', 'auth_token', 'option:piwik__auth_token', _t('Piwik Auth Token', 'piwik'));
     $form->append('checkbox', 'trackloggedin', 'option:piwik__trackloggedin', _t('Track logged-in users', 'piwik'));
     $form->append('checkbox', 'use_clickheat', 'option:piwik__use_clickheat', _t('Include PiWik Click Heat Plugin JS', 'piwik'));
     $form->append('submit', 'save', _t('Save', 'piwik'));
     $form->on_success(array($this, 'save_config'));
     return $form->get();
 }
Ejemplo n.º 5
0
 /**
  * filter_dash_module_latest_log_activity
  * Sets theme variables and handles logic for the
  * dashboard's log history module.
  * @param string $module_id
  * @return string The contents of the module
  */
 public function filter_dash_module_latest_log_activity($module, $module_id, $theme)
 {
     if (FALSE === ($num_logs = Modules::get_option($module_id, 'logs_number_display'))) {
         $num_logs = 8;
     }
     $params = array('where' => array('user_id' => User::identify()->id), 'orderby' => 'id DESC', 'limit' => $num_logs);
     $theme->logs = EventLog::get($params);
     // Create options form
     $form = new FormUI('dash_logs');
     $form->append('text', 'logs_number_display', 'option:' . Modules::storage_name($module_id, 'logs_number_display'), _t('Number of items'));
     $form->append('submit', 'submit', _t('Submit'));
     $form->properties['onsubmit'] = "dashboard.updateModule({$module_id}); return false;";
     $module['title'] = User::identify()->can('manage_logs') ? '<a href="' . Site::get_url('admin') . '/logs">' . _t('Latest Log Activity') . '</a>' : _t('Latest Log Activity');
     $module['options'] = $form->get();
     $module['content'] = $theme->fetch('dash_logs');
     return $module;
 }
Ejemplo n.º 6
0
 /**
  * Function used to set theme variables to the add module dashboard widget.
  * TODO make this form use an AJAX call instead of reloading the page
  */
 public function filter_dash_module_add_item($module, $id, $theme)
 {
     $modules = Modules::get_all();
     if ($modules) {
         $modules = array_combine(array_values($modules), array_values($modules));
     }
     $form = new FormUI('dash_additem');
     $form->append('select', 'module', 'null:unused');
     $form->module->options = $modules;
     $form->append('submit', 'submit', _t('+'));
     //$form->on_success( array( $this, 'dash_additem' ) );
     $form->properties['onsubmit'] = "dashboard.add(); return false;";
     $theme->additem_form = $form->get();
     $module['content'] = $theme->fetch('dash_additem');
     $module['title'] = _t('Add Item');
     return $module;
 }
Ejemplo n.º 7
0
 /**
  * Handles POST requests from the options admin page
  */
 public function post_options()
 {
     $form = new FormUI('Admin Options', 'admin_options');
     $this->theme->form = $form->get();
     $this->theme->display('options');
 }
	/**
	 * Provide requested media panels for this plugin
	 *
	 * Regarding Uploading:
	 * A panel is returned to the media bar that contains a form, an iframe, and a javascript function.
	 * The form allows the user to select a file, and is submitted back to the same URL that produced this panel in the first place.
	 * This has the result of submitting the uploaded file to here when the form is submitted.
	 * To prevent the panel form from reloading the whole publishing page, the form is submitted into the iframe.
	 * An onload event attached to the iframe calls the function.
	 * The function accesses the content of the iframe when it loads, which should contain the results of the request to obtain this panel, which are in JSON format.
	 * The JSON data is passed to the habari.media.jsonpanel() function in media.js to process the data and display the results, just like when displaying a panel normally.
	 *
	 * @param string $panel The HTML content of the panel to be output in the media bar
	 * @param MediaSilo $silo The silo for which the panel was requested
	 * @param string $path The path within the silo (silo root omitted) for which the panel was requested
	 * @param string $panelname The name of the requested panel
	 * @return string The modified $panel to contain the HTML output for the requested panel
	 *
	 * @todo Move the uploaded file from the temporary location to the location indicated by the path field.
	 */
	public function filter_media_panels( $panel, $silo, $path, $panelname)
	{
		$class = __CLASS__;
		if ( $silo instanceof $class ) {
			switch ( $panelname ) {
				case 'mkdir':

					$fullpath = self::SILO_NAME . '/' . $path;

					$form = new FormUI( 'habarisilomkdir' );
					$form->append( 'static', 'ParentDirectory', '<div style="margin: 10px auto;">' . _t('Parent Directory:') . " <strong>/{$path}</strong></div>" );

					// add the parent directory as a hidden input for later validation
					$form->append( 'hidden', 'path', 'null:unused' )->value = $path;
					$form->append( 'hidden', 'action', 'null:unused')->value = $panelname;
					$dir_text_control = $form->append( 'text', 'directory', 'null:unused', _t('What would you like to call the new directory?') );
					$dir_text_control->add_validator( array( $this, 'mkdir_validator' ) );
					$form->append( 'submit', 'submit', _t('Submit') );
					$form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
					$form->on_success( array( $this, 'dir_success' ) );
					$panel = $form->get(); /* form submission magicallly happens here */

					return $panel;

					break;
				case 'rmdir':
					$fullpath = self::SILO_NAME . '/' . $path;

					$form = new FormUI( 'habarisilormdir' );
					$form->append( 'static', 'RmDirectory', '<div style="margin: 10px auto;">' . _t('Directory:') . " <strong>/{$path}</strong></div>" );

					// add the parent directory as a hidden input for later validation
					$form->append( 'hidden', 'path', 'null:unused' )->value = $path;
					$form->append( 'hidden', 'action', 'null:unused')->value = $panelname;
					$dir_text_control = $form->append( 'static', 'directory', _t('Are you sure you want to delete this directory?') );
					$form->append( 'submit', 'submit', _t('Delete') );
					$form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
					$form->on_success( array( $this, 'dir_success' ) );
					$panel = $form->get(); /* form submission magicallly happens here */

					return $panel;

					break;
				case 'delete':
					$fullpath = self::SILO_NAME . '/' . $path;

					$form = new FormUI( 'habarisilodelete' );
					$form->append( 'static', 'RmFile', '<div style="margin: 10px auto;">' . _t('File:') . " <strong>/{$path}</strong></div>" );

					// add the parent directory as a hidden input for later validation
					$form->append( 'hidden', 'path', 'null:unused' )->value = $path;
					$dir_text_control = $form->append( 'static', 'directory', '<p>' . _t('Are you sure you want to delete this file?') . '</p>');
					$form->append( 'submit', 'submit', _t('Delete') );
					$form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
					$form->on_success( array( $this, 'do_delete' ) );
					$panel = $form->get();

					return $panel;
					break;
				case 'upload':
					if ( isset( $_FILES['file'] ) ) {
						$size = Utils::human_size($_FILES['file']['size']);
						$panel .= "<div class=\"span-18\" style=\"padding-top:30px;color: #e0e0e0;margin: 0px auto;\"><p>" . _t( "File Uploaded: " ) . "{$_FILES['file']['name']} ($size)</p>";

						$path = self::SILO_NAME . '/' . preg_replace('%\.{2,}%', '.', $path). '/' . $_FILES['file']['name'];
						$asset = new MediaAsset($path, false);
						$asset->upload( $_FILES['file'] );

						if ( $asset->put() ) {
							$panel .= '<p>' . _t( 'File added successfully.' ) . '</p>';
						}
						else {
							$panel .= '<p>' . _t( 'File could not be added to the silo.' ) . '</p>';
						}

						$panel .= '<p><a href="#" onclick="habari.media.forceReload();habari.media.showdir(\'' . dirname($path) . '\');">' . _t( 'Browse the current silo path.' ) . '</a></p></div>';
					}
					else {

						$fullpath = self::SILO_NAME . '/' . $path;
						$form_action = URL::get('admin_ajax', array('context' => 'media_panel'));
						$panel .= <<< UPLOAD_FORM
<form enctype="multipart/form-data" method="post" id="simple_upload" target="simple_upload_frame" action="{$form_action}" class="span-10" style="margin:0px auto;text-align: center">
	<p style="padding-top:30px;">%s <b style="font-weight:normal;color: #e0e0e0;font-size: 1.2em;">/{$path}</b></p>
	<p><input type="file" name="file"><input type="submit" name="upload" value="%s">
	<input type="hidden" name="path" value="{$fullpath}">
	<input type="hidden" name="panel" value="{$panelname}">
	</p>
</form>
<iframe id="simple_upload_frame" name="simple_upload_frame" style="width:1px;height:1px;" onload="simple_uploaded();"></iframe>
<script type="text/javascript">
var responsedata;
function simple_uploaded() {
	if (!$('#simple_upload_frame')[0].contentWindow) return;
	var response = $($('#simple_upload_frame')[0].contentWindow.document.body).text();
	if (response) {
		eval('responsedata = ' + response);
		window.setTimeout(simple_uploaded_complete, 500);
	}
}
function simple_uploaded_complete() {
	habari.media.jsonpanel(responsedata);
}
</script>
UPLOAD_FORM;

					$panel = sprintf( $panel, _t( "Upload to:" ), _t( "Upload" ) );
				}
			}
		}
		return $panel;
	}
Ejemplo n.º 9
0
 /**
  * Prepare and display admin page
  *
  **/
 public function action_admin_theme_get_menus(AdminHandler $handler, Theme $theme)
 {
     $theme->page_content = '';
     $action = isset($_GET['action']) ? $_GET['action'] : 'create';
     switch ($action) {
         case 'edit':
             $vocabulary = Vocabulary::get_by_id(intval($handler->handler_vars['menu']));
             if ($vocabulary == false) {
                 $theme->page_content = _t('<h2>Invalid Menu.</h2>', 'termmenus');
                 // that's it, we're done. Maybe we show the list of menus instead?
                 break;
             }
             $form = new FormUI('edit_menu');
             $form->append(new FormControlText('menuname', 'null:null', _t('Name', 'termmenus'), 'transparent_text'))->add_validator('validate_required', _t('You must supply a valid menu name', 'termmenus'))->add_validator(array($this, 'validate_newvocab'))->value = $vocabulary->name;
             $form->append(new FormControlHidden('oldname', 'null:null'))->value = $vocabulary->name;
             $form->append(new FormControlText('description', 'null:null', _t('Description', 'termmenus'), 'transparent_text'))->value = $vocabulary->description;
             $edit_items_array = $this->get_menu_type_data();
             $edit_items = '';
             foreach ($edit_items_array as $action => $menu_type) {
                 $edit_items .= '<a class="modal_popup_form menu_button_dark" href="' . URL::get('admin', array('page' => 'menu_iframe', 'action' => $action, 'menu' => $vocabulary->id)) . "\">" . _t('Add %s', array($menu_type['label']), 'termmenus') . "</a>";
             }
             if (!$vocabulary->is_empty()) {
                 $form->append('tree', 'tree', $vocabulary->get_tree(), _t('Menu', 'termmenus'));
                 $form->tree->config = array('itemcallback' => array($this, 'tree_item_callback'));
                 //						$form->tree->value = $vocabulary->get_root_terms();
                 // append other needed controls, if there are any.
                 $form->append('static', 'buttons', _t("<div id='menu_item_button_container'>{$edit_items}</div>", 'termmenus'));
                 $form->append('submit', 'save', _t('Apply Changes', 'termmenus'));
             } else {
                 $form->append('static', 'buttons', _t("<div id='menu_item_button_container'>{$edit_items}</div>", 'termmenus'));
             }
             $delete_link = URL::get('admin', array('page' => 'menus', 'action' => 'delete_menu', 'menu' => $handler->handler_vars['menu']));
             $form->append('static', 'deletebutton', _t("<a class='a_button' href='{$delete_link}'>Delete Menu</a>", 'termmenus'));
             $form->append(new FormControlHidden('menu', 'null:null'))->value = $handler->handler_vars['menu'];
             $form->on_success(array($this, 'rename_menu_form_save'));
             $form->properties['onsubmit'] = "return habari.menu_admin.submit_menu_update();";
             $theme->page_content .= $form->get();
             break;
         case 'create':
             $form = new FormUI('create_menu');
             $form->append('text', 'menuname', 'null:null', _t('Menu Name', 'termmenus'), 'transparent_text')->add_validator('validate_required', _t('You must supply a valid menu name', 'termmenus'))->add_validator(array($this, 'validate_newvocab'));
             $form->append('text', 'description', 'null:null', _t('Description', 'termmenus'), 'transparent_text');
             $form->append('submit', 'submit', _t('Create Menu', 'termmenus'));
             $form->on_success(array($this, 'add_menu_form_save'));
             $theme->page_content = $form->get();
             break;
         case 'delete_menu':
             $menu_vocab = Vocabulary::get_by_id(intval($handler->handler_vars['menu']));
             $menu_vocab->delete();
             // log that it has been deleted?
             Session::notice(_t('Menu deleted.', 'termmenus'));
             // redirect to a blank menu creation form
             Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'create')));
             break;
         case 'delete_term':
             $term = Term::get(intval($handler->handler_vars['term']));
             $menu_vocab = $term->vocabulary_id;
             $term->delete();
             // log that it has been deleted?
             Session::notice(_t('Item deleted.', 'termmenus'));
             Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $menu_vocab)));
             break;
         default:
             Utils::debug($_GET, $action);
             die;
     }
     $theme->display('menus_admin');
     // End everything
     exit;
 }
Ejemplo n.º 10
0
 /**
  * Prepare and display admin page
  *
  */
 public function action_admin_theme_get_menus(AdminHandler $handler, Theme $theme)
 {
     $theme->page_content = '';
     $action = isset($_GET['action']) ? $_GET['action'] : 'create';
     switch ($action) {
         case 'edit':
             $vocabulary = Vocabulary::get_by_id(intval($handler->handler_vars['menu']));
             if ($vocabulary == false) {
                 $theme->page_content = '<h2>' . _t('Invalid Menu.');
                 // that's it, we're done. Maybe we show the list of menus instead?
                 break;
             }
             $form = new FormUI('edit_menu');
             $form->append(new FormControlText('menuname', 'null:null', _t('Name'), 'transparent_text'))->add_validator('validate_required', _t('You must supply a valid menu name'))->add_validator(array($this, 'validate_newvocab'))->value = $vocabulary->name;
             $form->append(new FormControlHidden('oldname', 'null:null'))->value = $vocabulary->name;
             $form->append(new FormControlText('description', 'null:null', _t('Description'), 'transparent_text'))->value = $vocabulary->description;
             $edit_items_array = $this->get_menu_type_data();
             $edit_items = '';
             foreach ($edit_items_array as $action => $menu_type) {
                 $edit_items .= '<a class="modal_popup_form menu_button_dark" href="' . URL::get('admin', array('page' => 'menu_iframe', 'action' => $action, 'menu' => $vocabulary->id)) . "\">" . _t('Add %s', array($menu_type['label'])) . "</a>";
             }
             if (!$vocabulary->is_empty()) {
                 $form->append('tree', 'tree', $vocabulary->get_tree(), _t('Menu'));
                 $form->tree->options = $vocabulary->get_tree();
                 $form->tree->config = array('itemcallback' => array($this, 'tree_item_callback'));
                 //						$form->tree->value = $vocabulary->get_root_terms();
                 // append other needed controls, if there are any.
                 $form->append('static', 'buttons', '<div id="menu_item_button_container">' . $edit_items . '</div>');
                 $form->append('submit', 'save', _t('Apply Changes'));
             } else {
                 $form->append('static', 'buttons', '<div id="menu_item_button_container">' . $edit_items . '</div>');
             }
             $delete_link = URL::get('admin', Utils::WSSE(array('page' => 'menus', 'action' => 'delete_menu', 'menu' => $handler->handler_vars['menu'])));
             //$delete_link = URL::get( 'admin', array( 'page' => 'menus', 'action' => 'delete_menu', 'menu' => $handler->handler_vars[ 'menu' ] ) );
             $form->append('static', 'deletebutton', '<a class="a_button" href="' . $delete_link . '">' . _t('Delete Menu') . '</a>');
             $form->append(new FormControlHidden('menu', 'null:null'))->value = $handler->handler_vars['menu'];
             $form->on_success(array($this, 'rename_menu_form_save'));
             $form->properties['onsubmit'] = "return habari.menu_admin.submit_menu_update();";
             $theme->page_content .= $form->get();
             break;
         case 'create':
             $form = new FormUI('create_menu');
             $form->append('text', 'menuname', 'null:null', _t('Menu Name'), 'transparent_text')->add_validator('validate_required', _t('You must supply a valid menu name'))->add_validator(array($this, 'validate_newvocab'));
             $form->append('text', 'description', 'null:null', _t('Description'), 'transparent_text');
             $form->append('submit', 'submit', _t('Create Menu'));
             $form->on_success(array($this, 'add_menu_form_save'));
             $theme->page_content = $form->get();
             break;
         case 'delete_menu':
             if (Utils::verify_wsse($_GET, true)) {
                 $menu_vocab = Vocabulary::get_by_id(intval($handler->handler_vars['menu']));
                 // Delete blocks using this menu
                 $at = Themes::get_active_data(true);
                 $t = Themes::create(Themes::get_active()['name']);
                 $i = 0;
                 foreach ($at['areas'] as $area) {
                     foreach ($t->get_blocks($area['name'], 0, $t) as $block) {
                         if ($block->type == 'menu' && $block->menu_taxonomy == $handler->handler_vars['menu']) {
                             $block->delete();
                             $i++;
                         }
                     }
                 }
                 Session::notice(sprintf(_n('%s block linking to this menu deleted.', '%s blocks linking to this menu deleted.', $i), $i));
                 $menu_vocab->delete();
                 // log that it has been deleted?
                 Session::notice(_t('Menu deleted.'));
                 // redirect to a blank menu creation form
                 Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'create')));
             } else {
                 Session::notice(_t('Menu deletion failed - please try again.'));
                 Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $handler->handler_vars['menu'])));
             }
             break;
         case 'delete_term':
             $term = Term::get(intval($handler->handler_vars['term']));
             $menu_vocab = $term->vocabulary_id;
             if (Utils::verify_wsse($_GET, true)) {
                 $term->delete();
                 // log that it has been deleted?
                 Session::notice(_t('Item deleted.'));
                 Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $menu_vocab)));
             } else {
                 Session::notice(_t('Item deletion failed - please try again.'));
                 Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $menu_vocab)));
             }
             break;
         default:
             Utils::debug($_GET, $action);
             die;
     }
     $theme->display('menus_admin');
     // End everything
     exit;
 }
Ejemplo n.º 11
0
    /**
     * Display the different media panels
     *
     * @param string $panel HTML content to be output
     * @param object $silo Silo object
     * @param string $path Current silo path
     * @param string $panelname Curren panel name
     * @return string The modified panel output
     */
    public function filter_media_panels($panel, $silo, $path, $panelname)
    {
        $class = __CLASS__;
        if ($silo instanceof $class) {
            switch ($panelname) {
                case 'new-album':
                    $fullpath = self::SILO_NAME . '/' . $path;
                    $form = new FormUI('picasasilo-newalbum');
                    $today = date('d/m/Y', time());
                    // first column
                    $form->append('static', 'col1', '<div class="column">');
                    $form->append('text', 'album_name', 'null:unused', 'Album name');
                    $form->append('textarea', 'album_summary', 'null:unused', 'Summary');
                    $form->append('text', 'album_date', 'null:unused', 'Date');
                    $form->album_date->value = $today;
                    $form->append('static', 'col2', '</div>');
                    // second column
                    $form->append('static', 'col3', '<div class="column">');
                    $form->append('text', 'album_location', 'null:unused', 'Location');
                    $form->append('select', 'album_visibility', 'null:unused', 'Visibility');
                    $form->album_visibility->options = array('public' => 'Public', 'private' => 'Anyone with the link', 'protected' => 'Private');
                    $form->append('static', 'col4', '</div>');
                    // clear columns
                    $form->append('static', 'colend', '<br style="clear: both">');
                    $form->append('submit', 'create-album', 'Create');
                    $form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
                    $form->on_success(array($this, 'create_album'));
                    $panel = $form->get();
                    return $panel;
                    break;
                case 'upload':
                    if (isset($_FILES['upload_file'])) {
                        $panel = $this->upload_photo();
                    } else {
                        $fullpath = self::SILO_NAME . '/' . $path;
                        $action = URL::get('admin_ajax', array('context' => 'media_panel'));
                        $picasa = new Picasa();
                        // collect album names
                        $xml = $picasa->get_albums();
                        foreach ($xml->channel->item as $album) {
                            $title = (string) $album->title;
                            $options .= "<option value='" . $title . "'>" . $title . "</option>";
                        }
                        // create a form that sends the request to an IFrame (as done in the Habari Silo)
                        $static = <<<PICASA_UPLOAD
\t\t\t\t\t\t<form enctype="multipart/form-data" method="post" id="picasasilo-upload" target="picasa_upload_frame" action="{$action}" class="span-10" style="margin:0px auto;" target="picasa_upload_frame">

\t\t\t\t\t\t  <div class="formcontrol"><input type="file" name="upload_file"></div>
  \t\t\t\t\t\t<div class="formcontrol">
\t\t\t\t\t\t\t\t<label for="upload">Album:</label>
\t\t\t\t\t\t\t\t<select name="upload_album">{$options}</select>
\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t<div class="formcontrol">
\t\t\t\t\t\t\t\t<label for="summary">Summary:</label>
\t\t\t\t\t\t\t\t<textarea name="summary"></textarea>
\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t  <div class="formcontrol"><input type="submit" name="upload" value="Upload"></div>
\t\t\t\t\t\t  <input type="hidden" name="path" value="{$fullpath}">
\t\t\t\t\t\t  <input type="hidden" name="panel" value="{$panelname}">
\t\t\t\t\t\t  
            </form>

\t\t\t\t\t\t<iframe id="picasa_upload_frame" name="picasa_upload_frame" style="width:1px;height:1px;" onload="picasa_uploaded();">
\t\t\t\t\t\t</iframe>

\t\t\t\t\t\t<script type="text/javascript">
\t\t\t\t\t\t\t\tvar responsedata;
\t\t\t\t\t      function picasa_uploaded() 
\t\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\t\tif(!jQuery('#picasa_upload_frame')[0].contentWindow)return;
\t\t\t\t\t\t\t\t\tvar response = jQuery(jQuery('#picasa_upload_frame')[0].contentWindow.document.body).text();
\t\t\t\t\t\t\t\t\tif(response) 
\t\t\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\t\t\teval('responsedata = ' + response);
\t\t\t\t\t\t\t\t\t\twindow.setTimeout(picasa_uploaded_complete, 500);
\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t}

\t\t\t\t\t\t\t\tfunction picasa_uploaded_complete() 
\t\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\t\thabari.media.jsonpanel(responsedata);
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t</script>
PICASA_UPLOAD;
                        $panel = $static;
                    }
                    return $panel;
                    break;
            }
        }
    }
Ejemplo n.º 12
0
 /**
  * filter: dash_module_fire_eagle
  *
  * @access public
  * @param array $module
  * @param string $module_id
  * @param object $theme
  * @return array
  */
 public function filter_dash_module_fire_eagle($module, $module_id, $theme)
 {
     $module['title'] = _t('Fire Eagle', 'fireeagle') . '<img src="' . $this->get_url() . '/img/fireeagle.png" alt= "Fire Eagle" />';
     $form = new FormUI('dash_fireeagle');
     $form->append('text', 'location', 'null:unused', _t('Location: ', 'fireeagle'));
     $user = User::identify();
     if (isset($user->info->fireeagle_location)) {
         $form->location->value = $user->info->fireeagle_location;
     }
     $form->append('submit', 'submit', _t('Update', 'fireeagle'));
     $form->properties['onsubmit'] = 'fireeagle.update(); return false;';
     $theme->fireeagle_form = $form->get();
     $module['content'] = $theme->fetch('dash_fireeagle');
     return $module;
 }
Ejemplo n.º 13
0
 /**
  * Implement the simple plugin configuration.
  * @return FormUI The configuration form
  */
 public function configure()
 {
     $form = new FormUI('blogroll');
     // display settings
     $display_wrap = $form->append('fieldset', 'display', _t('Display Settings', self::DOMAIN));
     $title = $display_wrap->append('text', 'list_title', 'option:blogroll__list_title', _t('List title: ', self::DOMAIN));
     $max = $display_wrap->append('text', 'max_links', 'option:blogroll__max_links', _t('Max. displayed links: ', self::DOMAIN));
     $sort_bys = array_merge(array_combine(array_keys(Post::default_fields()), array_map('ucwords', array_keys(Post::default_fields()))), array('RAND()' => _t('Randomly', self::DOMAIN)));
     $sortby = $display_wrap->append('select', 'sort_by', 'option:blogroll__sort_by', _t('Sort By: ', self::DOMAIN), $sort_bys);
     $orders = array('ASC' => _t('Ascending', self::DOMAIN), 'DESC' => _t('Descending', self::DOMAIN));
     $order = $display_wrap->append('select', 'direction', 'option:blogroll__direction', _t('Order: ', self::DOMAIN), $orders);
     // other settings
     $other_wrap = $form->append('fieldset', 'settings', _t('More Settings', self::DOMAIN));
     $update = $other_wrap->append('checkbox', 'use_updated', 'option:blogroll__use_updated', _t('Use Weblogs.com to get updates? ', self::DOMAIN));
     $form->append('submit', 'save', 'Save');
     $form->on_success(array($this, 'formui_submit'));
     return $form->get();
 }
Ejemplo n.º 14
0
 function test_encode_textinput()
 {
     $form = new FormUI('encode');
     $encoded = $form->append('text', 'encoded')->set_value('<b>strong</b>')->add_class('target');
     $html = $form->get();
     $this->assert_true(strpos($html, 'value="&lt;b&gt;strong&lt;/b&gt;"') !== false, 'The output value was not encoded.');
     $encoded->set_value('&lt;b&gt;strong&lt;/b&gt;');
     $html = $form->get();
     $this->assert_true(strpos($html, 'value="&amp;lt;b&amp;gt;strong&amp;lt;/b&amp;gt;"') !== false, 'The output value was not encoded.');
 }
 /**
  * Creates (attaches) the 'add new option' form/tab
  * @todo Determine if this is a hack :)
  *
  * @param  $theme The theme being attached to
  * @return Theme The modified Theme object
  */
 public function create_add_option_form_tab(Theme $theme)
 {
     $form = new FormUI('options-view-new');
     $form->set_option('form_action', URL::get('admin', 'page=options_view'));
     $form->class[] = 'form comment';
     $tabs = $form->append('tabs', 'publish_controls');
     $new = $tabs->append('fieldset', 'settings', _t('Add a new option'));
     $action = $new->append('hidden', 'action', 'null:null');
     $action->value = 'add';
     $name = $new->append('text', 'option_name', 'null:null', _t('Name'), 'tabcontrol_text');
     $name->value = '';
     $name->helptext = _t('Name of the new option');
     $value = $new->append('text', 'option_value', 'null:null', _t('Value'), 'tabcontrol_text');
     $value->value = '';
     $value->helptext = _t('Value of the new option');
     $new->append('submit', 'save', _t('Save'));
     $form->on_success(array($this, 'formui_submit_add'));
     $theme->form = $form->get();
     return $theme;
 }
Ejemplo n.º 16
0
    /**
     * Provide requested media panels for this plugin
     *
     * Regarding Uploading:
     * A panel is returned to the media bar that contains a form, an iframe, and a javascript function.
     * The form allows the user to select a file, and is submitted back to the same URL that produced this panel in the first place.
     * This has the result of submitting the uploaded file to here when the form is submitted.
     * To prevent the panel form from reloading the whole publishing page, the form is submitted into the iframe.
     * An onload event attached to the iframe calls the function.
     * The function accesses the content of the iframe when it loads, which should contain the results of the request to obtain this panel, which are in JSON format.
     * The JSON data is passed to the habari.media.jsonpanel() function in media.js to process the data and display the results, just like when displaying a panel normally.
     *
     * @param string $panel The HTML content of the panel to be output in the media bar
     * @param MediaSilo $silo The silo for which the panel was requested
     * @param string $path The path within the silo (silo root omitted) for which the panel was requested
     * @param string $panelname The name of the requested panel
     * @return string The modified $panel to contain the HTML output for the requested panel
     *
     * @todo Move the uploaded file from the temporary location to the location indicated by the path field.
     */
    public function filter_media_panels($panel, $silo, $path, $panelname)
    {
        $class = __CLASS__;
        if ($silo instanceof $class) {
            switch ($panelname) {
                case 'mkdir':
                    $fullpath = self::SILO_NAME . '/' . $path;
                    $form = new FormUI('habarisilomkdir');
                    $form->append('static', 'ParentDirectory', '<div style="margin: 10px auto;">' . _t('Parent Directory:') . " <strong>/{$path}</strong></div>");
                    // add the parent directory as a hidden input for later validation
                    $form->append('hidden', 'path', 'null:unused')->value = $path;
                    $form->append('hidden', 'action', 'null:unused')->value = $panelname;
                    $dir_text_control = $form->append('text', 'directory', 'null:unused', _t('What would you like to call the new directory?'));
                    $dir_text_control->add_validator(array($this, 'mkdir_validator'));
                    $form->append('submit', 'submit', _t('Submit'));
                    $form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
                    $form->on_success(array($this, 'dir_success'));
                    $panel = $form->get();
                    /* form submission magicallly happens here */
                    return $panel;
                    break;
                case 'rmdir':
                    $fullpath = self::SILO_NAME . '/' . $path;
                    $form = new FormUI('habarisilormdir');
                    $form->append('static', 'RmDirectory', '<div style="margin: 10px auto;">' . _t('Directory:') . " <strong>/{$path}</strong></div>");
                    // add the parent directory as a hidden input for later validation
                    $form->append('hidden', 'path', 'null:unused')->value = $path;
                    $form->append('hidden', 'action', 'null:unused')->value = $panelname;
                    $dir_text_control = $form->append('static', 'directory', _t('Are you sure you want to delete this directory?'));
                    $form->append('submit', 'submit', _t('Delete'));
                    $form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
                    $form->on_success(array($this, 'dir_success'));
                    $panel = $form->get();
                    /* form submission magicallly happens here */
                    return $panel;
                    break;
                case 'delete':
                    $fullpath = self::SILO_NAME . '/' . $path;
                    $form = new FormUI('habarisilodelete');
                    $form->append('static', 'RmFile', '<div style="margin: 10px auto;">' . _t('File:') . " <strong>/{$path}</strong></div>");
                    // add the parent directory as a hidden input for later validation
                    $form->append('hidden', 'path', 'null:unused')->value = $path;
                    $dir_text_control = $form->append('static', 'directory', '<p>' . _t('Are you sure you want to delete this file?') . '</p>');
                    $form->append('submit', 'submit', _t('Delete'));
                    $form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
                    $form->on_success(array($this, 'do_delete'));
                    $panel = $form->get();
                    return $panel;
                    break;
                case 'upload':
                    if (isset($_FILES['file'])) {
                        if (isset($_POST['token']) && isset($_POST['token_ts']) && self::verify_token($_POST['token'], $_POST['token_ts'])) {
                            $size = Utils::human_size($_FILES['file']['size']);
                            $panel .= '<div class="span-18" style="padding-top:30px;color: #e0e0e0;margin: 0px auto;"><p>' . _t('File: ') . $_FILES['file']['name'];
                            $panel .= $_FILES['file']['size'] > 0 ? "({$size})" : '';
                            $panel .= '</p>';
                            $path = self::SILO_NAME . '/' . preg_replace('%\\.{2,}%', '.', $path) . '/' . $_FILES['file']['name'];
                            $asset = new MediaAsset($path, false);
                            $asset->upload($_FILES['file']);
                            if ($asset->put()) {
                                $msg = _t('File uploaded: %s', array($_FILES['file']['name']));
                                $panel .= '<p>' . $msg . '</p>';
                                EventLog::log($msg, 'info');
                            } else {
                                $upload_errors = array(1 => _t('The uploaded file exceeds the upload_max_filesize directive in php.ini.'), 2 => _t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'), 3 => _t('The uploaded file was only partially uploaded.'), 4 => _t('No file was uploaded.'), 6 => _t('Missing a temporary folder.'), 7 => _t('Failed to write file to disk.'), 8 => _t('A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.'));
                                $msg = _t('File upload failed: %s', array($_FILES['file']['name']));
                                $panel .= '<p>' . $msg . '</p>';
                                $panel .= '<p><strong>' . $upload_errors[$_FILES['file']['error']] . '</strong></p>';
                                EventLog::log($msg . ' ' . $upload_errors[$_FILES['file']['error']], 'err');
                            }
                            $panel .= '<p><a href="#" onclick="habari.media.forceReload();habari.media.showdir(\'' . dirname($path) . '\');">' . _t('Browse the current silo path.') . '</a></p></div>';
                        } else {
                            $panel .= '<p><strong>' . _t('Suspicious behaviour or too much time has elapsed.  Please upload your file again.') . '</strong></p>';
                        }
                    } else {
                        $token_ts = time();
                        $token = self::create_token($token_ts);
                        $fullpath = self::SILO_NAME . '/' . $path;
                        $form_action = URL::get('admin_ajax', array('context' => 'media_upload'));
                        $panel .= <<<UPLOAD_FORM
<form enctype="multipart/form-data" method="post" id="simple_upload" target="simple_upload_frame" action="{$form_action}" class="span-10" style="margin:0px auto;text-align: center">
\t<p style="padding-top:30px;">%s <b style="font-weight:normal;color: #e0e0e0;font-size: 1.2em;">/{$path}</b></p>
\t<p><input type="file" name="file"><input type="submit" name="upload" value="%s">
\t<input type="hidden" name="path" value="{$fullpath}">
\t<input type="hidden" name="panel" value="{$panelname}">
\t<input type="hidden" name="token" value="{$token}">
\t<input type="hidden" name="token_ts" value="{$token_ts}">
\t</p>
</form>
<iframe id="simple_upload_frame" name="simple_upload_frame" style="width:1px;height:1px;" onload="simple_uploaded();"></iframe>
<script type="text/javascript">
var responsedata;
function simple_uploaded() {
\tif (!\$('#simple_upload_frame')[0].contentWindow) return;
\tvar response = \$(\$('#simple_upload_frame')[0].contentWindow.document.body).text();
\tif (response) {
\t\teval('responsedata = ' + response);
\t\twindow.setTimeout(simple_uploaded_complete, 500);
\t}
}
function simple_uploaded_complete() {
\thabari.media.jsonpanel(responsedata.data);
}
</script>
UPLOAD_FORM;
                        $panel = sprintf($panel, _t("Upload to:"), _t("Upload"));
                    }
            }
        }
        return $panel;
    }
Ejemplo n.º 17
0
    public function action_admin_theme_get_clickheat($handler, $theme)
    {
        $vars = $handler->handler_vars;
        $this->is_clickheat = true;
        $this->theme = $theme;
        // load required items from logs
        $this->load_groups();
        // confirm group count
        if (count($this->groups) == 0) {
            $this->is_clickheat = false;
            $theme->display('header');
            echo "<div class=\"container\"><span class=\"error\">" . _t("No logs exist. Please wait until someone clicks somewhere.") . "</div>";
            $theme->display('footer');
            exit;
        }
        // Date
        $this->date = isset($vars['date']) ? strtotime($vars['date']) : (Options::get('clickheat__yesterday') ? mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')) : false);
        if ($this->date === false) {
            $this->date = time();
        }
        $this->day = (int) date('d', $this->date);
        $this->month = (int) date('m', $this->date);
        $this->year = (int) date('Y', $this->date);
        $option_fields = array('group' => array('label' => _t('Group'), 'type' => 'select', 'selectarray' => $this->groups), 'screen' => array('label' => _t('Screen Size'), 'type' => 'select', 'selectarray' => $this->screenSizes), 'heatmap' => array('label' => _t('Heatmap'), 'type' => 'checkbox', 'value' => Options::get('clickheat__heatmap')));
        $form = new FormUI('Clickheat View');
        foreach ($option_fields as $option_name => $option) {
            $field = $form->append($option['type'], $option_name, $option_name, $option['label']);
            $field->template = 'optionscontrol_' . $option['type'];
            $field->class = 'item clear nomargin';
            if ($option['type'] == 'select' && isset($option['selectarray'])) {
                $field->options = $option['selectarray'];
            } else {
                $field->value = $option['value'];
            }
        }
        $field = $form->append('static', 'alpha', '<div class="item clear nomargin" id="alpha">
					<span class="pct25"><label>' . _t('Transparency') . '</label></span>
					<span class="pct25"><span id="alphaSelector"></span></span>
					</div>');
        $theme->form = $form->get();
        require "view.php";
        exit;
    }
 public function action_admin_theme_get_cronjob(AdminHandler $handler, Theme $theme)
 {
     $cron = CronTab::get_cronjob((int) $handler->handler_vars['cron_id']);
     $theme->cron = $cron;
     $form = new FormUI('cronjob');
     $cron_id = $form->append('hidden', 'cron_id', 'null:null');
     $cron_id->value = (int) $handler->handler_vars['cron_id'];
     $name = $form->append('text', 'cron_name', 'null:null', _t('Name', 'crontabmanager'), 'optionscontrol_text');
     $name->class = 'item clear';
     $name->value = $cron->name;
     $name->helptext = _t('A unique name for this cronjob.', 'crontabmanager');
     $callback = $form->append('text', 'callback', 'null:null', _t('Callback', 'crontabmanager'), 'optionscontrol_text');
     $callback->class = 'item clear';
     $callback->value = is_array($cron->callback) ? htmlspecialchars(serialize($cron->callback)) : $cron->callback;
     $callback->helptext = _t('A valid callback OR plugin filter name.', 'crontabmanager');
     $increment = $form->append('text', 'increment', 'null:null', _t('Iterval', 'crontabmanager'), 'optionscontrol_text');
     $increment->class = 'item clear';
     $increment->value = $cron->increment;
     $increment->helptext = _t('The interval, in seconds, between executions.', 'crontabmanager');
     $next_run = $form->append('text', 'next_run', 'null:null', _t('Next Run', 'crontabmanager'), 'optionscontrol_text');
     $next_run->class = 'item clear';
     $next_run->value = $cron->next_run->get();
     $next_run->helptext = _t('A valid HabariDateTime formatted string.', 'crontabmanager');
     $start_time = $form->append('text', 'start_time', 'null:null', _t('Start Time', 'crontabmanager'), 'optionscontrol_text');
     $start_time->class = 'item clear';
     $start_time->value = $cron->start_time->get();
     $start_time->helptext = _t('A valid HabariDateTime formatted string.', 'crontabmanager');
     $end_time = $form->append('text', 'end_time', 'null:null', _t('End Time', 'crontabmanager'), 'optionscontrol_text');
     $end_time->class = 'item clear';
     $end_time->value = $cron->end_time ? $cron->end_time->get() : $cron->end_time;
     $end_time->helptext = _t('A valid HabariDateTime formatted string OR empty for "never".', 'crontabmanager');
     $description = $form->append('text', 'description', 'null:null', _t('Description', 'crontabmanager'), 'optionscontrol_text');
     $description->class = 'item clear';
     $description->value = $cron->description;
     $description->helptext = _t('A string describing the Cron Job.', 'crontabmanager');
     $cron_class = $form->append('select', 'cron_class', 'null:null', _t('Cron Class', 'crontabmanager'), 'optionscontrol_select');
     $cron_class->class = 'item clear';
     $cron_class->value = $cron->cron_class;
     $cron_class->helptext = _t('The type of Cron Job.', 'crontabmanager');
     $cron_class->options = array(CronJob::CRON_SYSTEM => _t('System', 'crontabmanager'), CronJob::CRON_THEME => _t('Theme', 'crontabmanager'), CronJob::CRON_PLUGIN => _t('Plugin', 'crontabmanager'), CronJob::CRON_CUSTOM => _t('Custom', 'crontabmanager'));
     $form->append('submit', 'save', _t('Save', 'crontabmanager'));
     $form->on_success(array($this, 'formui_submit'));
     $theme->form = $form->get();
 }
Ejemplo n.º 19
0
 /**
  * Builds and returns the form for the first stage of the importer
  * @param array The list of importers the plugin contains
  * @param string The name of the current importer
  *
  * @return FormUI The FormUI element used to chose the importer
  */
 public function get_form($importers, $importer)
 {
     $form = new FormUI('import');
     if (count($importers) == 0) {
         $form->append(FormControlStatic(' <p>' . _t('You do not currently have any import plugins installed.') . '</p>'));
         $form->append(FormControlStatic(' <p>' . _t('Please <a href="%1$s">activate an import plugin</a> to enable importing.', array(URL::get('display_plugins'))) . '</p>'));
     } else {
         $form->append(FormControlLabel::wrap(_t('Please choose the type of import to perform:'), FormControlSelect::create('importer')->set_options(array_combine($importers, $importers))));
         $form->append(FormControlSubmit::create('import')->set_caption(_t('Select')));
     }
     return $form->get();
 }
    /**
     * Plugin UI
     *
     * @access public
     * @return void
     */
    public function action_plugin_ui_configure()
    {
        $this->add_template('hbap_checkbox', dirname($this->get_file()) . '/lib/formcontrols/hbap_checkbox.php');
        $this->add_template('hbap_text', dirname($this->get_file()) . '/lib/formcontrols/hbap_text.php');
        $this->add_template('hbap_select', dirname($this->get_file()) . '/lib/formcontrols/hbap_select.php');
        $options = Options::get(self::OPTNAME);
        $ui = new FormUI(strtolower(__CLASS__));
        $ui->append('wrapper', 'colourselector', 'formcontrol');
        // First all the hidden settings
        foreach ($options['colorScheme'] as $opt => $value) {
            $ui->colourselector->append('hidden', "cs_" . $opt, 'null:null');
            $optn = "cs_{$opt}";
            if ($optn == 'cs_pagebg') {
                continue;
            }
            $ui->colourselector->{$optn}->value = '#' . $value;
            $ui->colourselector->{$optn}->id = $optn . "color";
        }
        if (Plugins::is_loaded('Habari Media Silo')) {
            // Get a list of all the directories available in the loaded Habari Silo
            $dirs = self::siloDirs();
            $dirs['custom'] = _t('Custom', 'audio-player');
        }
        $ui->append('fieldset', 'genfs', _t('General', 'audio-player'));
        $ui->genfs->append('select', 'defaultPath', 'null:null', _t('Default Audio Path', 'audio-player'));
        $ui->genfs->defaultPath->template = 'hbap_select';
        $ui->genfs->defaultPath->id = 'defaultPath';
        $ui->genfs->defaultPath->pct = 80;
        $ui->genfs->defaultPath->value = $options['defaultPath'];
        $ui->genfs->defaultPath->helptext = _t('This is the default location for your audio files. When you use the [audio] syntax and don\'t provide an absolute URL for the mp3 file (the full URL including "http://") Audio Player will automatically look for the file in this location. You can set this to a folder located inside your blog folder structure or, alternatively, if you wish to store your audio files outside your blog (maybe even on a different server), choose "Custom" from the drop down and enter the absolute URL to that location.', 'audio-player');
        $ui->genfs->defaultPath->options = $dirs;
        $ui->genfs->append('text', 'customPath', 'null:null', _t('Custom Audio Path:', 'audio-player'), 'hbap_text');
        $ui->genfs->customPath->value = $options['customPath'];
        $ui->genfs->customPath->pct = 80;
        $ui->genfs->customPath->id = 'customPath';
        if ($options['defaultPath'] != 'custom') {
            $ui->genfs->customPath->disabled = TRUE;
        }
        $ui->append('fieldset', 'appfs', _t('Appearance', 'audio-player'));
        $ui->appfs->append('text', 'width', 'null:null', _t('Player Width', 'audio-player'), 'hbap_text');
        $ui->appfs->width->value = $options['width'];
        $ui->appfs->width->helptext = _t('You can enter a value in pixels (e.g. 200) or as a percentage (e.g. 100%)', 'audio-player');
        $ui->appfs->append('select', 'fieldsel', 'null:null', _t('Colour Scheme Selector', 'audio-player'));
        $ui->appfs->fieldsel->id = 'fieldsel';
        $ui->appfs->fieldsel->template = 'hbap_select';
        $ui->appfs->fieldsel->options = array('bg' => _t('Background', 'audio-player'), 'leftbg' => _t('Left Background', 'audio-player'), 'lefticon' => _t('Left Icon', 'audio-player'), 'volslider' => _t('Volume Control Slider', 'audio-player'), 'voltrack' => _t('Volume Control Track', 'audio-player'), 'rightbg' => _t('Right Background', 'audio-player'), 'rightbghover' => _t('Right Background (hover)', 'audio-player'), 'righticon' => _t('Right Icon', 'audio-player'), 'righticonhover' => _t('Right Icon (hover)', 'audio-player'), 'text' => _t('Text', 'audio-player'), 'track' => _t('Progress Bar Track', 'audio-player'), 'tracker' => _t('Progress Bar', 'audio-player'), 'loader' => _t('Loading Bar', 'audio-player'), 'border' => _t('Progress Bar Border', 'audio-player'), 'skip' => _t('Next/Previous Buttons', 'audio-player'));
        $ui->appfs->fieldsel->helptext = '<input name="colorvalue" type="text" id="colorvalue" size="10" maxlength="7" />
												  <span id="colorsample"></span>';
        // IFF we've managed to find the theme/style.css file and parse it, we'll show the "Theme Colours" selection tool
        $themeColors = self::getThemeColors();
        if (is_array($themeColors) && !empty($themeColors)) {
            $themeColorStr = '';
            foreach (self::getThemeColors() as $themeColor) {
                $themeColorStr .= "<li style='background:#{$themeColor}' title='#{$themeColor}'>#{$themeColor}</li>";
            }
            $ui->appfs->fieldsel->helptext .= '<span id="themecolor-btn">' . _t('Theme Colours', 'audio-player') . '</span>
														<div id="themecolor">
														<span>' . _t('Theme Colours', 'audio-player') . '</span>
														<ul>' . $themeColorStr . '</ul></div>';
        }
        $ui->appfs->fieldsel->helptext .= '<input type="button" class="submit" id="doresetcolors" value="' . _t('Reset Color Scheme', 'audio-player') . '">';
        $ui->appfs->append('hidden', 'resetColors', 'null:null');
        $ui->appfs->resetColors->id = 'resetColors';
        $ui->appfs->append('wrapper', 'colour_selector_demo', 'formcontrol');
        $ui->appfs->colour_selector_demo->append('static', 'demo', '
					<div id="demoplayer">Audio Player</div>
					<script type="text/javascript">
					AudioPlayer.embed("demoplayer", {demomode:"yes"});
					</script>
				');
        $ui->appfs->append('text', 'cs_pagebg', 'null:null', _t('Page Background', 'audio-player'), 'hbap_text');
        $ui->appfs->cs_pagebg->value = '#' . $options['colorScheme']['pagebg'];
        $ui->appfs->cs_pagebg->id = 'cs_pagebg';
        if ($options['colorScheme']['transparentpagebg']) {
            $ui->appfs->cs_pagebg->disabled = TRUE;
        }
        $ui->appfs->cs_pagebg->helptext = _t('In most cases, simply select "transparent" and it will match the background of your page. In some rare cases, the player will stop working in Firefox if you use the transparent option. If this happens, untick the transparent box and enter the color of your page background in the box below (in the vast majority of cases, it will be white: #FFFFFF).', 'audio-player');
        $ui->appfs->append('checkbox', 'cs_transparentpagebg', 'null:null', _t('Transparent Page Background', 'audio-player'));
        $ui->appfs->cs_transparentpagebg->value = $options['colorScheme']['transparentpagebg'];
        $ui->appfs->append('checkbox', 'enableAnimation', 'null:null', _t('Enable Animation', 'audio-player'), 'hbap_checkbox');
        $ui->appfs->enableAnimation->value = $options['enableAnimation'];
        $ui->appfs->enableAnimation->helptext = _t('If you don\'t like the open/close animation, you can disable it here.', 'audio-player');
        $ui->appfs->append('checkbox', 'showRemaining', 'null:null', _t('Show Remaining', 'audio-player'), 'hbap_checkbox');
        $ui->appfs->showRemaining->value = $options['showRemaining'];
        $ui->appfs->showRemaining->helptext = _t('This will make the time display count down rather than up.', 'audio-player');
        $ui->appfs->append('checkbox', 'disableTrackInformation', 'null:null', _t('Disable Track Information', 'audio-player'), 'hbap_checkbox');
        $ui->appfs->disableTrackInformation->value = $options['disableTrackInformation'];
        $ui->appfs->disableTrackInformation->helptext = _t('Select this if you wish to disable track information display (the player won\'t show titles or artist names even if they are available.)', 'audio-player');
        $ui->appfs->append('checkbox', 'rtlMode', 'null:null', _t('Switch to RTL Layout', 'audio-player'), 'hbap_checkbox');
        $ui->appfs->rtlMode->value = $options['rtlMode'];
        $ui->appfs->rtlMode->helptext = _t('Select this to switch the player layout to RTL mode (right to left) for Arabic and Hebrew language blogs.', 'audio-player');
        $ui->append('fieldset', 'feedfs', _t('Feed', 'audio-player'));
        $ui->feedfs->append('select', 'feedAlt', 'null:null', _t('Alternate Content', 'audio-player'));
        $ui->feedfs->feedAlt->id = 'feedAlt';
        $ui->feedfs->feedAlt->template = 'hbap_select';
        $ui->feedfs->feedAlt->value = $options['feedAlt'];
        $ui->feedfs->feedAlt->options = array('enclosure' => _t('Enclosure', 'audio-player'), 'download' => _t('Download Link', 'audio-player'), 'nothing' => _t('Nothing', 'audio-player'), 'custom' => _t('Custom', 'audio-player'));
        $ui->feedfs->feedAlt->helptext = _t('The following options determine what is included in your feeds. The plugin doesn\'t place a player instance in the feed. Instead, you can choose what the plugin inserts. You have four choices:<br /><br />
					<strong>Enclosure</strong>: Choose this if you want your audio file included as an enclosure in your feed.<br>
					<strong>Download link</strong>: Choose this if you are OK with subscribers downloading the file.<br>
					<strong>Nothing</strong>: Choose this if you feel that your feed shouldn\'t contain any reference to the audio file.<br>
					<strong>Custom</strong>: Choose this to use your own alternative content for all player instances. You can use this option to tell subscribers that they can listen to the audio file if they read the post on your blog.', 'audio-player');
        $ui->feedfs->append('text', 'feedCustom', 'null:null', _t('Custom alternate content', 'audio-player'), 'hbap_text');
        $ui->feedfs->feedCustom->value = $options['feedCustom'];
        $ui->feedfs->feedCustom->pct = 80;
        $ui->feedfs->feedCustom->id = 'feedCustom';
        if ($options['feedAlt'] != 'custom') {
            $ui->feedfs->feedCustom->disabled = TRUE;
        }
        $ui->append('fieldset', 'advfs', _t('Advanced', 'audio-player'));
        $ui->advfs->append('text', 'initVol', 'null:null', _t('Initial Volume', 'audio-player'), 'hbap_text');
        $ui->advfs->initVol->value = $options['initVol'];
        $ui->advfs->initVol->helptext = _t('This is the volume at which the player defaults to (0 is off, 100 is full volume)', 'audio-player');
        $ui->advfs->append('text', 'buffer', 'null:null', _t('Buffer time (in seconds)', 'audio-player'), 'hbap_text');
        $ui->advfs->buffer->value = $options['buffer'];
        $ui->advfs->buffer->helptext = _t('If you think your target audience is likely to have a slow internet connection, you can increase the player\'s buffering time (for standard broadband connections, 5 seconds is enough)', 'audio-player');
        $ui->advfs->append('checkbox', 'chkPolicy', 'null:null', _t('Check for policy file', 'audio-player'), 'hbap_checkbox');
        $ui->advfs->chkPolicy->value = $options['chkPolicy'];
        $ui->advfs->chkPolicy->helptext = _t('Enable this to tell Audio Player to check for a policy file on the server. This allows Flash to read ID3 tags on remote servers. Only enable this if all your mp3 files are located on a server with a policy file.', 'audio-player');
        $ui->advfs->append('checkbox', 'encode', 'null:null', _t('Encode MP3 URLs', 'audio-player'), 'hbap_checkbox');
        $ui->advfs->encode->value = $options['encode'];
        $ui->advfs->encode->helptext = _t('Enable this to encode the URLs to your mp3 files. This is the only protection possible against people downloading the mp3 file to their computers.', 'audio-player');
        $ui->append('submit', 'save', _t('Save', 'audio-player'));
        $ui->on_success(array($this, 'storeOpts'));
        //$ui->set_option( 'success_message', _t( 'Options successfully saved.' ) );
        $form_output = $ui->get();
        echo '<script type="text/javascript">AudioPlayer.setup("' . URL::get_from_filesystem(__FILE__) . '/lib/player.swf",' . self::php2js(self::getPlayerOptions()) . ');</script>';
        echo $form_output;
    }
Ejemplo n.º 21
0
 /**
  * Display the page
  **/
 public function action_admin_theme_get_shelves(AdminHandler $handler, Theme $theme)
 {
     $all_terms = array();
     $all_terms = $this->vocabulary->get_tree();
     $one_shelf = ucfirst(Options::get('shelves__single', _t('shelf', 'shelves')));
     if (!isset($_GET['shelf'])) {
         // create new shelf form
         $form = new FormUI('shelf-new');
         $form->set_option('form_action', URL::get('admin', 'page=shelves'));
         $create_fieldset = $form->append('fieldset', '', _t('Create a new %s', array($one_shelf), 'shelves'));
         $shelf = $create_fieldset->append('text', 'shelf', 'null:null', $one_shelf, 'formcontrol_text');
         $shelf->add_validator('validate_required');
         $shelf->class = 'pct30';
         $parent = $create_fieldset->append('select', 'parent', 'null:null', _t('Parent', 'shelves'), 'optionscontrol_select');
         // $template doesn't work
         $parent->class = 'pct50';
         $parent->options = array();
         $parent->options[''] = '';
         // top should be blank
         $right = array();
         foreach ($all_terms as $term) {
             while (count($right) > 0 && $right[count($right) - 1] < $term->mptt_right) {
                 array_pop($right);
             }
             $parent->options[$term->id] = str_repeat(' - ', count($right)) . $term->term_display;
             $right[] = $term->mptt_right;
         }
         $save_button = $create_fieldset->append('submit', 'save', _t('Create', 'shelves'));
         $save_button->class = 'pct20 last';
         $cancelbtn = $form->append('button', 'btn', _t('Cancel', 'shelves'));
         $form->on_success(array($this, 'formui_create_submit'));
     } else {
         // edit form for existing shelf
         $which_shelf = $_GET['shelf'];
         $shelf_term = $this->vocabulary->get_term($which_shelf);
         if (!$shelf_term) {
             exit;
         }
         $parent_term = $shelf_term->parent();
         if (!$parent_term) {
             $parent_term_display = _t('none', 'shelves');
         } else {
             $parent_term_display = $parent_term->term_display;
         }
         $form = new FormUI('shelf-edit');
         $form->set_option('form_action', URL::get('admin', 'page=shelves&shelf=' . $_GET['shelf']));
         $shelf_id = $form->append('hidden', 'shelf_id')->value = $shelf_term->id;
         // send this id, for seeing what has changed
         $edit_fieldset = $form->append('fieldset', '', _t('Edit %1$s: <b>%2$s</b>', array($one_shelf, $shelf_term->term_display), 'shelves'));
         $shelf = $edit_fieldset->append('text', 'shelf', 'null:null', _t('Rename %s', array($one_shelf), 'shelves'), 'formcontrol_text');
         $shelf->value = $shelf_term->term_display;
         $shelf->add_validator('validate_required');
         $shelf->class = 'pct30';
         $parent = $edit_fieldset->append('select', 'parent', 'null:null', sprintf(_t('Current Parent: <b>%1$s</b> Change Parent to:', 'shelves'), $parent_term_display), 'asdasdaoptionscontrol_select');
         $parent->class = 'pct50';
         $parent->options = array();
         $parent->options[''] = '';
         // top should be blank
         $right = array();
         foreach ($shelf_term->not_descendants() as $term) {
             while (count($right) > 0 && $right[count($right) - 1] < $term->mptt_right) {
                 array_pop($right);
             }
             $parent->options[$term->id] = str_repeat(' - ', count($right)) . $term->term_display;
             $right[] = $term->mptt_right;
         }
         $parent->value = !$parent_term ? '' : $parent_term->id;
         // select the current parent
         $save_button = $edit_fieldset->append('submit', 'save', _t('Edit', 'shelves'));
         $save_button->class = 'pct20 last';
         $cancel_button = $form->append('submit', 'cancel_btn', _t('Cancel', 'shelves'));
         $form->on_success(array($this, 'formui_edit_submit'));
     }
     $theme->form = $form->get();
     $theme->display('shelves');
     // End everything
     exit;
 }