Started to work on frontend code
This commit is contained in:
parent
20c5c9d147
commit
0048f63990
@ -8,7 +8,8 @@ defined('_JEXEC') or die;
|
||||
|
||||
JLoader::discover('Clubs', JPATH_ROOT . '/administrator/components/com_clubs/mymodels');
|
||||
|
||||
JLoader::register("ClubsHelperAuth", JPATH_ROOT . "/components/com_clubs/helpers/auth.php");
|
||||
JLoader::registerPrefix('ClubsHelper', JPATH_ROOT . '/components/com_clubs/helpers');
|
||||
JLoader::registerPrefix('ClubsPart', JPATH_ROOT . '/components/com_clubs/parts');
|
||||
|
||||
JLoader::registerPrefix('AbstractClubs', JPATH_ROOT . '/administrator/components/com_clubs/abstract');
|
||||
|
||||
|
18
src/site/helpers/part/textarea.php
Normal file
18
src/site/helpers/part/textarea.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
abstract class ClubsHelperPartTextarea extends ClubsHelperParts
|
||||
{
|
||||
|
||||
public function getEditMarkup()
|
||||
{
|
||||
$ret = '<textarea name="value">';
|
||||
$ret .= $this->getEditContent();
|
||||
$ret .= '</textarea>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
18
src/site/helpers/part/textfield.php
Normal file
18
src/site/helpers/part/textfield.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
abstract class ClubsHelperPartTextfield extends ClubsHelperParts
|
||||
{
|
||||
|
||||
public function getEditMarkup()
|
||||
{
|
||||
$ret = '<input type="text" name="value" value="';
|
||||
$ret .= $this->getEditContent();
|
||||
$ret .= '">';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
59
src/site/helpers/parts.php
Normal file
59
src/site/helpers/parts.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
abstract class ClubsHelperParts
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getPartName();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEditPart()
|
||||
{
|
||||
$partname = $this->getPartName();
|
||||
|
||||
$ret = "<form method='POST' action='index.php?option=com_clubs&task=parts.edit&format=json' class='clubs-part'>";
|
||||
$ret .= "<input type='hidden' name='partname' value='$partname'>";
|
||||
$ret .= $this->getEditMarkup();
|
||||
$ret .= ' <a class="clubs-save" href="#"><span class="icon-ok"></span></a> ';
|
||||
$ret .= '<a class="clubs-abort" href="index.php?option=com_clubs&view=mypage&layout=parts&type='.$partname.'"><span class="icon-cancel-2"></span></a>';
|
||||
$ret .= '</form>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
abstract protected function getEditMarkup();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getEditContent();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getViewContent()
|
||||
{
|
||||
return $this->getEditContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getViewPart()
|
||||
{
|
||||
$ret = '';
|
||||
|
||||
$ret = "<a class='clubs-edit' href='index.php?option=com_clubs&view=mypage&layout=parts&mode=edit&type=" . $this->getPartName();
|
||||
$ret .= $this->getViewContent();
|
||||
$ret .= "<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span></a>";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
21
src/site/parts/user/name.php
Normal file
21
src/site/parts/user/name.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class ClubsPartUserName extends ClubsHelperPartTextfield
|
||||
{
|
||||
protected function getPartName()
|
||||
{
|
||||
return 'user.name';
|
||||
}
|
||||
|
||||
protected function getEditContent()
|
||||
{
|
||||
$auth = new ClubsHelperAuth();
|
||||
$user = $auth->getCurrentUser();
|
||||
|
||||
return htmlentities($user->getName());
|
||||
}
|
||||
|
||||
}
|
74
src/site/views/part/view.html.php
Normal file
74
src/site/views/part/view.html.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\HtmlView;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class ClubsViewPart extends HtmlView
|
||||
{
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// $auth = new ClubsHelperAuth();
|
||||
// $this->me = $auth->getCurrentUser();
|
||||
|
||||
// $this->clubsPresident = $this->me->getPresidentClubs();
|
||||
// $this->positions = $this->me->getPositions();
|
||||
|
||||
// HTMLHelper::_('jquery.framework');
|
||||
// Factory::getDocument()->addScript(Uri::base(true) . "components/com_clubs/js/edit.js");
|
||||
// parent::display($tpl);
|
||||
|
||||
$app = Factory::getApplication();
|
||||
$input = $app->input;
|
||||
|
||||
$mode = $input->get->getCmd('mode', 'view');
|
||||
$type = $input->get->getCmd('type');
|
||||
|
||||
$parthandler = $this->getPart($type);
|
||||
|
||||
if($mode === 'view')
|
||||
$this->view($parthandler);
|
||||
else
|
||||
$this->edit($parthandler);
|
||||
|
||||
jexit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClubsHelperParts $parthandler
|
||||
*/
|
||||
private function view($parthandler)
|
||||
{
|
||||
echo $parthandler->getViewPart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClubsHelperParts $parthandler
|
||||
*/
|
||||
private function edit($parthandler)
|
||||
{
|
||||
echo $parthandler->getEditPart();
|
||||
}
|
||||
|
||||
private function getPart($type)
|
||||
{
|
||||
if(! preg_match('/.*\..*/', $type))
|
||||
throw new Exception();
|
||||
|
||||
list($obj, $fcn) = explode('.', $type, 2);
|
||||
switch($obj)
|
||||
{
|
||||
case 'user':
|
||||
switch($fcn)
|
||||
{
|
||||
case 'name':
|
||||
return new ClubsPartUserName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user