Beispiel #1
0
 public static function render($page, $position = '')
 {
     $page = !$page ? 'null' : $page;
     if (Cache::tags('widgets')->has($page . '-' . $position)) {
         $merged = Cache::tags('widgets')->get($page . '-' . $position);
     } else {
         if ($page == 'null') {
             $merged = Widget::select('id', 'title', 'content', 'path')->active()->global()->wherePosition($position)->orderBy('ordr', 'ASC')->get();
         } else {
             $global = Widget::select('id', 'title', 'content', 'path')->active()->global()->wherePosition($position)->orderBy('ordr', 'ASC')->get();
             $specific = $page->widgets()->select('id', 'title', 'content', 'path')->local()->wherePosition($position)->orderBy('ordr', 'ASC')->get();
             $merged = $global->merge($specific);
         }
         $merged->sortBy('ordr');
         Cache::tags('widgets')->forever($page . '-' . $position, $merged);
     }
     foreach ($merged as $widget) {
         if ($widget->path) {
             if (\View::exists($widget->path)) {
                 echo view($widget->path);
             }
         } else {
             echo str_replace('{{url}}', Request::url(), $widget->content);
         }
     }
 }
Beispiel #2
0
 /**
  * Show a list of all the widgets formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function data()
 {
     //Make this method testable and mockable by using our injected $widget member.
     $widgets = $this->widget->select(array('widgets.id', 'widgets.name', 'widgets.description', 'widgets.created_at'));
     return Datatables::of($widgets)->add_column('actions', '<div class="btn-group">
               <button type="button" class="btn btn-xs btn-primary dropdown-toggle" data-toggle="dropdown">
                 Action <span class="caret"></span>
               </button>
               <ul class="dropdown-menu" role="menu">
                 <li><a href="{{{ URL::to(\'widgets/\' . $id ) }}}">{{{ Lang::get(\'button.show\') }}}</a></li>
                 <li><a href="{{{ URL::to(\'widgets/\' . $id . \'/edit\' ) }}}">{{{ Lang::get(\'button.edit\') }}}</a></li>
                 <li><a href="{{{ URL::to(\'widgets/\' . $id . \'/delete\' ) }}}">{{{ Lang::get(\'button.delete\') }}}</a></li>
               </ul>
             </div>')->remove_column('id')->make();
 }
		public function appendPreferences($context) {
			$group = new XMLElement('fieldset');
			$group->setAttribute('class', 'settings');
			$group->appendChild(
				new XMLElement('legend', 'markItUp Editor')
			);

			$options = array(
				array('Markdown',  General::sanitize($this->getFormatter()) == 'Markdown'),
				array('Textile',  General::sanitize($this->getFormatter()) == 'Textile')
			);

			$formatter = Widget::Label('Text Formatter');
			$formatter->appendChild(Widget::select(
				'settings[markitup][textformatter]', $options

			));
			$group->appendChild($formatter);

			$context['wrapper']->appendChild($group);
		}
		public function __viewEdit() {
			$this->setPageType('form');
			$title = ($this->_editing ? $this->_fields['name'] : 'Untitled');
			$this->setTitle("Symphony &ndash; Redirection Manager &ndash; {$title}");
			$this->appendSubheading("<a href=\"{$this->_uri}/rules/\">Rules</a> &mdash; {$title}");
			
			if (!$this->_valid) $this->pageAlert('
				An error occurred while processing this form.
				<a href="#error">See below for details.</a>',
				AdministrationPage::PAGE_ALERT_ERROR
			);
			
			// Status message:
			if ($this->_status) {
				$action = null;
				
				switch ($this->_status) {
					case 'saved': $action = 'updated'; break;
					case 'created': $action = 'created'; break;
				}
				
				if ($action) {
					Administration::instance()->Page->pageAlert(
						__('Rule '.$action.' succesfully.') . ' <a href="' . URL . 'extension/redirectionmanager/rules/new/'.'">Create another?</a>',
						Alert::SUCCESS
					);
				}
				$this->pageAlert(
					__(
						$action, array(
							__('Template'), 
							DateTimeObj::get(__SYM_TIME_FORMAT__), 
							URL . '/symphony/extension/emailtemplatefilter/templates/new/', 
							URL . '/symphony/extension/emailtemplatefilter/templates/',
							__('Templates')
						)
					),
					Alert::SUCCESS
				);
				
				
			}
			
		// Fields -------------------------------------------------------------
			
			$fieldset = new XMLElement('fieldset');
			$fieldset->setAttribute('class', 'settings');
			$fieldset->appendChild(new XMLElement('legend', 'Essentials'));
			
			if (!empty($this->_fields['id'])) {
				$fieldset->appendChild(Widget::Input("fields[id]", $this->_fields['id'], 'hidden'));
			}
			
		// Title --------------------------------------------------------------
			
			$label = Widget::Label('Name');
			$label->appendChild(Widget::Input(
				'fields[name]',
				General::sanitize($this->_fields['name'])
			));
			
			if (isset($this->_errors['name'])) {
				$label = Widget::wrapFormElementWithError($label, $this->_errors['name']);
			}
			
			$fieldset->appendChild($label);
			
			
		// Source --------------------------------------------------------------
			
			$label = Widget::Label('Source');
			
			if (isset($_GET["source"])) {
				$label->appendChild(Widget::Input(
					'fields[source]',
					General::sanitize($_GET["source"])
				));
			} else {
				$label->appendChild(Widget::Input(
					'fields[source]',
					General::sanitize($this->_fields['source'])
				));
			}
			
			if (isset($this->_errors['source'])) {
				$label = Widget::wrapFormElementWithError($label, $this->_errors['source']);
			}
		
			
			
			$fieldset->appendChild($label);
			
			
		// Target --------------------------------------------------------------
			
			$label = Widget::Label('Target');
			$label->appendChild(Widget::Input(
				'fields[target]',
				General::sanitize($this->_fields['target'])
			));
			
			if (isset($this->_errors['target'])) {
				$label = Widget::wrapFormElementWithError($label, $this->_errors['target']);
			}
			
			$fieldset->appendChild($label);
	
			
		// Method -------------------------------------------------------------
			
			$group = new XMLElement('div');
			$group->setAttribute('class', 'redirectionmanager_group');
			
			$input = Widget::Input(
				'fields[method]', 'regexp', 'checkbox',
				($this->_fields['method'] == 'regexp' ? array('checked' => 'checked') : null)
			);
			$input = $input->generate();
			
			$label = Widget::Label("{$input} Use regular expressions?");
			
			$group->appendChild($label);
			
			$help = new XMLElement('p');
			$help->setAttribute('class', 'help');
			$help->setValue("
				Use * as a wild-card unless regular expressions are enabled.
			");
			
			$group->appendChild($help);
			$fieldset->appendChild($group);
			$this->Form->appendChild($fieldset);
			
			
		// Type --------------------------------------------------------------	
			
			$options = array(
				array('301'),
				array('302'),
				array('307')
			);
		
			$label = Widget::Label('HTTP Type');
			$label->appendChild(Widget::select(
				'fields[type]', $options
				
			));
			
			if (isset($this->_errors['type'])) {
				$label = Widget::wrapFormElementWithError($label, $this->_errors['type']);
			}
			
			$fieldset->appendChild($label);
			
		// Save ---------------------------------------------------------------
			
			$div = new XMLElement('div');
			$div->setAttribute('class', 'actions');
			$div->appendChild(
				Widget::Input(
					'action[save]', 'Save Changes', 'submit',
					array(
						'accesskey'		=> 's'
					)
				)
			);
			
		// Delete -------------------------------------------------------------
			
			if ($this->_editing) {
				$button = new XMLElement('button', 'Delete');
				$button->setAttributeArray(array(
					'name'		=> 'action[delete]',
					'class'		=> 'confirm delete',
					'title'		=> 'Delete this email'
				));
				$div->appendChild($button);
			}
			
			$this->Form->appendChild($div);
		}
Beispiel #5
0
 protected function appendCondition(Duplicator $duplicator, $condition = array())
 {
     $document = $duplicator->ownerDocument;
     if (empty($condition)) {
         $item = $duplicator->createTemplate(__('Don\'t Execute When'));
     } else {
         $item = $duplicator->createInstance(__('Don\'t Execute When'));
     }
     if (!isset($condition['parameter'])) {
         $condition['parameter'] = null;
     }
     if (!isset($condition['logic'])) {
         $condition['logic'] = 'empty';
     }
     $group = $document->createElement('div');
     $group->setAttribute('class', 'group double');
     // Parameter
     $label = $document->createElement('label', __('Parameter'));
     $label->appendChild(Widget::input('fields[conditions][parameter][]', $condition['parameter']));
     $group->appendChild($label);
     // Logic
     $label = $document->createElement('label', __('Logic'));
     $label->appendChild(Widget::select('fields[conditions][logic][]', array(array('empty', $condition['logic'] == 'empty', __('is empty')), array('set', $condition['logic'] == 'set', __('is set'))), array('class' => 'filtered')));
     $group->appendChild($label);
     $group->appendChild($label);
     $item->appendChild($group);
 }
Beispiel #6
0
 function index(&$Page, &$Contents, $fields)
 {
     global $warnings;
     global $notices;
     $Form = new XMLElement('form');
     $Form->setAttribute('action', 'install.php');
     $Form->setAttribute('method', 'post');
     /**
      *
      * START ENVIRONMENT SETTINGS
      *
      **/
     /*
     		<fieldset>
     			<legend>Environment Settings</legend>
     			<p>Symphony is ready to be installed at the following location.</p>
     			<label class="warning">Root Path <input name="" value="/users/21degre/public_html/" /></label>
     			<p class="warning">No <code>/symphony</code> directory was found at this location. Please upload the contents of Symphony's install package here.</p>
     			<p class="note">An existing <code>/workspace</code> directory was found at this location. Symphony will use this workspace.</p>
     			<p class="warning">Symphony does not have write permission to the existing <code>/workspace</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.</p>
     			<p class="warning">Symphony does not have write permission to the <code>/manifest</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.</p>
     		</fieldset>
     */
     $Environment = new XMLElement('fieldset');
     $Environment->addChild(new XMLElement('legend', 'Environment Settings'));
     $Environment->addChild(new XMLElement('p', 'Symphony is ready to be installed at the following location.'));
     $class = NULL;
     if (defined('kENVIRONMENT_WARNING') && kENVIRONMENT_WARNING == true) {
         $class = 'warning';
     }
     $Environment->addChild(Widget::label('Root Path', Widget::input('fields[docroot]', $fields['docroot']), $class));
     if (defined('ERROR') && defined('kENVIRONMENT_WARNING')) {
         $Environment->addChild(Widget::warning($warnings[ERROR]));
     }
     ## CHECK FOR AN EXISTING WORKSPACE FOLDER
     if (!defined('ERROR') && @is_file($fields['docroot'] . '/workspace/workspace.conf')) {
         $Environment->addChild(Widget::note($notices['existing-workspace']));
     }
     $Form->addChild($Environment);
     /** END ENVIRONMENT SETTINGS **/
     /**
      *
      * START DATABASE SETTINGS
      *
      **/
     /*
     		<fieldset>
     			<legend>Database Connection</legend>
     			<p>Please provide Symphony with access to a database.</p>
     			<label class="warning">Database <input name="" /></label>
     			<div class="group warning">
     				<label>Username <input name="" /></label>
     				<label>Password <input name="" type="password" /></label>
     			</div>
     			<p class="warning">Symphony was unable to connect to the specified database. You may need to modify host or port settings.</p>
     
     			...
     
     		</fieldset>
     */
     $Database = new XMLElement('fieldset');
     $Database->addChild(new XMLElement('legend', 'Database Connection'));
     $Database->addChild(new XMLElement('p', 'Please provide Symphony with access to a database.'));
     $class = NULL;
     if (defined('kDATABASE_CONNECTION_WARNING') && kDATABASE_CONNECTION_WARNING == true) {
         $class = ' warning';
     }
     ## fields[database][name]
     $Database->addChild(Widget::label('Database', Widget::input('fields[database][name]', $fields['database']['name'])));
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group' . $class);
     ## fields[database][username]
     $Div->addChild(Widget::label('Username', Widget::input('fields[database][username]', $fields['database']['username'])));
     ## fields[database][password]
     $Div->addChild(Widget::label('Password', Widget::input('fields[database][password]', $fields['database']['password'], NULL, 'password')));
     $Database->addChild($Div);
     if (defined('ERROR') && defined('kDATABASE_CONNECTION_WARNING')) {
         $Database->addChild(Widget::warning($warnings[ERROR]));
     }
     /*
     
     			...
     
     			<fieldset>
     				<legend>Advanced Configuration</legend>
     				<p>Leave these fields unless you are sure they need to be changed.</p>
     				<div class="group">
     					<label>Host <input name="" value="localhost" /></label>
     					<label>Port <input name="" value="3306" /></label>
     				</div>
     				<label class="warning">Table Prefix <input name="" value="sym_" /></label>
     				<p class="warning">The table prefix <code>sym_</code> is already in use. Please choose a different prefix to use with Symphony.</p>
     				<label class="option"><input name="" type="checkbox" /> Use compatibility mode</label>
     				<p>Symphony normally specifies UTF-8 character encoding for database entries. With compatibility mode enabled, Symphony will instead use the default character encoding of your database.</p>
     			</fieldset>
     */
     $Fieldset = new XMLElement('fieldset');
     $Fieldset->addChild(new XMLElement('legend', 'Advanced Configuration'));
     $Fieldset->addChild(new XMLElement('p', 'Leave these fields unless you are sure they need to be changed.'));
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group');
     ## fields[database][host]
     $Div->addChild(Widget::label('Host', Widget::input('fields[database][host]', $fields['database']['host'])));
     ## fields[database][port]
     $Div->addChild(Widget::label('Port', Widget::input('fields[database][port]', $fields['database']['port'])));
     $Fieldset->addChild($Div);
     $class = NULL;
     if (defined('kDATABASE_PREFIX_WARNING') && kDATABASE_PREFIX_WARNING == true) {
         $class = 'warning';
     }
     ## fields[database][prefix]
     $Fieldset->addChild(Widget::label('Table Prefix', Widget::input('fields[database][prefix]', $fields['database']['prefix']), $class));
     if (defined('ERROR') && defined('kDATABASE_PREFIX_WARNING')) {
         $Fieldset->addChild(Widget::warning($warnings[ERROR]));
     }
     $Page->setTemplateVar('TABLE-PREFIX', $fields['database']['prefix']);
     ## fields[database][high-compatibility]
     $Fieldset->addChild(Widget::label('Use compatibility mode', Widget::input('fields[database][high-compatibility]', 'yes', NULL, 'checkbox'), 'option'));
     $Fieldset->addChild(new XMLElement('p', 'Symphony normally specifies UTF-8 character encoding for database entries. With compatibility mode enabled, Symphony will instead use the default character encoding of your database.'));
     $Database->addChild($Fieldset);
     $Form->addChild($Database);
     /** END DATABASE SETTINGS **/
     /**
      *
      * START PERMISSION SETTINGS
      *
      **/
     /*
     				<fieldset>
     					<legend>Permission Settings</legend>
     					<p>Symphony needs permission to read and write both files and directories.</p>
     					<div class="group">
     						<label>Files
     							<select name="">
     								<option value="0777">0777</option>
     							</select>
     						</label>
     						<label>Directories
     							<select name="">
     								<option value="0777">0777</option>
     							</select>
     						</label>
     					</div>
     				</fieldset>
     */
     $Permissions = new XMLElement('fieldset');
     $Permissions->addChild(new XMLElement('legend', 'Permission Settings'));
     $Permissions->addChild(new XMLElement('p', 'Symphony needs permission to read and write both files and directories.'));
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group');
     ## fields[permission][file]
     $Div->addChild(Widget::label('Files', Widget::select('fields[permission][file]', array('0777', '0775', '0755', '0666', '0644', '0444'), $fields['permission']['file'])));
     ## fields[permission][directory]
     $Div->addChild(Widget::label('Directories', Widget::select('fields[permission][directory]', array('0777', '0775', '0755', '0666', '0644', '0444'), $fields['permission']['directory'])));
     $Permissions->addChild($Div);
     $Form->addChild($Permissions);
     /** END PERMISSION SETTINGS **/
     /**
      *
      * START USER SETTINGS
      *
      **/
     /*
     		<fieldset>
     			<legend>User Information</legend>
     			<p>Once installed, you will be able to login to the Symphony admin with these user details.</p>
     			<label>Username <input name="" /></label>
     			<div class="group warning">
     				<label>Password <input name="" type="password" /></label>
     				<label>Confirm Password <input name="" type="password" /></label>
     			</div>
     			<p class="warning">The password and confirmation did not match. Please retype your password.</p>
     
     			...
     
     		</fieldset>
     */
     $User = new XMLElement('fieldset');
     $User->addChild(new XMLElement('legend', 'User Information'));
     $User->addChild(new XMLElement('p', 'Once installed, you will be able to login to the Symphony admin with these user details.'));
     $class = NULL;
     if (defined('kUSER_USERNAME_WARNING') && kUSER_PASSWORD_WARNING == true) {
         $class = 'warning';
     }
     ## fields[user][username]
     $User->addChild(Widget::label('Username', Widget::input('fields[user][username]', $fields['user']['username']), $class));
     if (defined('ERROR') && defined('kUSER_USERNAME_WARNING')) {
         $User->addChild(Widget::warning($warnings[ERROR]));
     }
     $class = NULL;
     if (defined('kUSER_PASSWORD_WARNING') && kUSER_PASSWORD_WARNING == true) {
         $class = ' warning';
     }
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group' . $class);
     ## fields[user][password]
     $Div->addChild(Widget::label('Password', Widget::input('fields[user][password]', $fields['user']['password'], NULL, 'password')));
     ## fields[user][confirm-password]
     $Div->addChild(Widget::label('Confirm Password', Widget::input('fields[user][confirm-password]', $fields['user']['confirm-password'], NULL, 'password')));
     $User->addChild($Div);
     if (defined('ERROR') && defined('kUSER_PASSWORD_WARNING')) {
         $User->addChild(Widget::warning($warnings[ERROR]));
     }
     /*
     
     			...
     
     			<fieldset>
     				<legend>Personal Information</legend>
     				<p>Please add the following personal details for this user.</p>
     				<div class="group">
     					<label>First Name <input name="" /></label>
     					<label>Last Name <input name="" /></label>
     				</div>
     				<label class="warning">Email Address <input name="" /></label>
     				<p class="warning">This is not a valid email address. You must provide an email address since you will need it if you forget your password.</p>
     			</fieldset>
     */
     $Fieldset = new XMLElement('fieldset');
     $Fieldset->addChild(new XMLElement('legend', 'Personal Information'));
     $Fieldset->addChild(new XMLElement('p', 'Please add the following personal details for this user.'));
     $class = NULL;
     if (defined('kUSER_NAME_WARNING') && kUSER_EMAIL_WARNING == true) {
         $class = ' warning';
     }
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group' . $class);
     ## fields[database][host]
     $Div->addChild(Widget::label('First Name', Widget::input('fields[user][firstname]', $fields['user']['firstname'])));
     ## fields[database][port]
     $Div->addChild(Widget::label('Last Name', Widget::input('fields[user][lastname]', $fields['user']['lastname'])));
     $Fieldset->addChild($Div);
     if (defined('ERROR') && defined('kUSER_NAME_WARNING')) {
         $Fieldset->addChild(Widget::warning($warnings[ERROR]));
     }
     $class = NULL;
     if (defined('kUSER_EMAIL_WARNING') && kUSER_EMAIL_WARNING == true) {
         $class = 'warning';
     }
     ## fields[user][email]
     $Fieldset->addChild(Widget::label('Email Address', Widget::input('fields[user][email]', $fields['user']['email']), $class));
     if (defined('ERROR') && defined('kUSER_EMAIL_WARNING')) {
         $Fieldset->addChild(Widget::warning($warnings[ERROR]));
     }
     $User->addChild($Fieldset);
     $Form->addChild($User);
     /** END USER SETTINGS **/
     /**
      *
      * START FORM SUBMIT AREA
      *
      **/
     $Form->addChild(new XMLElement('h2', 'Install Symphony'));
     $Form->addChild(new XMLElement('p', 'Make sure that you delete the <code>install.php</code> file after Symphony has installed successfully.'));
     $Submit = new XMLElement('div');
     $Submit->setAttribute('class', 'submit');
     ### submit
     $Submit->addChild(Widget::input('submit', 'Install Symphony', NULL, 'submit'));
     ### action[install]
     $Submit->addChild(Widget::input('action[install]', 'true', NULL, 'hidden'));
     $Form->addChild($Submit);
     $Contents->addChild($Form);
     /** END FORM SUBMIT AREA **/
     $Page->setTemplateVar('title', 'Install Symphony');
     $Page->setTemplateVar('tagline', 'Version ' . kVERSION);
 }