×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: php editing

php editing 9 years 4 months ago #29428

  • Philipp Teh
  • Philipp Teh's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 1
Hi there
Es gibt ja die Funktion, dass ich einer Veranstaltung eine Datei anhängen kann. Diese lässt sich in der Veranstaltungsübersicht auch downloaden.
Nun möchte ich jedoch einen Link direkt auf der Buchungsseite(bookings) erstellen, wo die Benutzer diese Datei downloaden können.
Den Button konnte ich erstellen, doch nicht den richtigen Link/Skript dazu.
Kann mir da jemand mit besseren php Kenntnissen weiterhelfen?



So sieht der original Code aus
<?php if ($files_html): ?>
					<div id="mat_event_files">
						<a href="#submenu_files" class="list-group-item list-group-item-grey" data-toggle="collapse">
							<?php echo JText::_("COM_MATUKIO_FILES"); ?>
							<span class="menu-ico-collapse pull-right"><i class="glyphicon glyphicon-plus-sign"></i></span>
						</a>
						<div class="collapse in list-group-submenu" id="submenu_files">
							<div class="list-group-item">
								<div class="row">
									<div class="col-sm-12">
										<?php echo $files_html; ?>
									</div>
								</div>
							</div>
						</div>
					</div>
				<?php endif; ?>
Und hier möchte ich diesen Code integrieren
// Files
		if (MatukioHelperSettings::_("mat_event_files", 1)
			&& ($this->booking->status == 0 || $this->booking->status == 1))
		{
			$href = JURI::ROOT() . "" . $this->booking->semid . "&uuid=" . $this->booking->uuid;
 
			echo " <a border=\"0\" href=\"" . $href
				. "\" target=_blank><span class=\"btn btn-default\" type=\"button\">" . JTEXT::_('COM_MATUKIO_FILES')
				. "</span></a>";
		}

Vielen Dank.
Gruss
Philipp
Attachments:

php editing 9 years 4 months ago #29430

  • Yves Hoppe
  • Yves Hoppe's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 3519
  • Karma: 71
  • Thank you received: 556
Hi Phillip,

als Erstes solltest du einen Template Override erstellen und nicht den Code selbst bearbeiten (Wegen Updates etc.):

docs.joomla.org/How_to_override_the_outp...rom_the_Joomla!_core

Für Datei-Buttons musst du einiges ändern und dem Code den du dir kopiert hast dem fehlt ja die $files_html (der Inhalt):

$files = MatukioHelperUtilsEvents::getEventFileArray($this->event);
$files_html = MatukioHelperRendering::getFilesList($this->event, $this->user, $files, $isBooked, $bookings);

Leider kannst du $files_html auch nicht direkt verwenden, da dies den HTML-Code für eine Tabellenansicht und nicht für Buttons generiert.

Also musst du selber über $files iterieren (Schleife - nehm dir MatukioHelperRendering::getFilesList(..) als Vorlage).

Zum Beispiel:
      $files = MatukioHelperUtilsEvents::getEventFileArray($this->event);
     for ($i = 0; $i < 5; $i++)
		{
			$filename = $files[0][$i];
 
			if ($filename)
			{
				$acl = $files[2][$i];
 
				$ispaid = false;
 
				if ($acl == 3 && $bookings)
				{
					// We need to check if user has paid
					foreach($bookings as $b)
					{
						if ($b->paid == 1)
						{
							$ispaid = true;
						}
					}
				}
 
				if ($acl == 0
					|| $acl == 1 && $user->id
					|| $acl == 2 && $user->id && $isbooked
					|| $acl == 3 && $user->id && $isbooked && $ispaid)
				{
					// Now we show the link etc. - security by obscurity! Awesome dirk! OpenSource? (TODO Fix!)
					$filelink = JRoute::_("index.php?option=com_matukio&view=matukio&task=downloadfile&a6d5dgdee4cu7eho8e7fc6ed4e76z="
						. sha1(md5($filename)) . $event->id
					);
 
					echo  '<a href="' . $filelink . '" title="' . $filename . '" class="btn btn-default">';
					echo = $filename;
					echo '</a>';
				}
			}
		}

Viele Grüße

Yves
The following user(s) said Thank You: Philipp Teh
  • Page:
  • 1
Time to create page: 0.111 seconds