1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-07 07:06:30 +02:00

Fixes #1186 - Added edit button for custom pages. Improved debugging of shortcodes and shortcode wrappers.

This commit is contained in:
Cameron
2016-04-02 10:51:18 -07:00
parent ec3e92b0d6
commit 46b2518e82
5 changed files with 78 additions and 10 deletions

View File

@@ -533,6 +533,31 @@ class cpage_shortcodes extends e_shortcode
}
function sc_cpageedit($parm=array())
{
if(!ADMIN || !getperms('5'))
{
return null;
}
$tp = e107::getParser();
if(!empty($parm['modal']))
{
$modal = 'e-modal';
$iframe = '&iframe=1';
}
else
{
$modal = '';
$iframe = '';
}
$icon = deftrue('FONTAWESOME') ? $tp->toGlyph('fa-edit') : "<img src='".e_IMAGE_ABS."/admin_images/edit_16.png' alt='edit' style='border: 0px none; height: 16px; width: 16px;' />";
return "<a rel='external' title=\"".LAN_EDIT."\" data-modal-caption=\"".LAN_EDIT."\" class='btn btn-default ".$modal."' href='".e_ADMIN_ABS."cpage.php?action=edit&id=".$this->var['page_id'].$iframe."' >".$icon."</a>";
}
}

View File

@@ -9,7 +9,8 @@
*/
if (!defined('e107_INIT')) { exit; }
$PAGE_WRAPPER = array();
global $sc_style;
$sc_style['CPAGEAUTHOR|default']['pre'] = '';
@@ -49,8 +50,11 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
<div class="clear"><!-- --></div>
{CPAGERATING|default}
{CPAGEEDIT}
';
$PAGE_WRAPPER['default']['CPAGEEDIT'] = "<div class='text-right'>{---}</div>";
// used only when password authorization is required
$PAGE_TEMPLATE['default']['authorize'] = '
<div class="cpage-restrict ">

View File

@@ -517,10 +517,16 @@ class e107_db_debug {
</thead>
<tbody>\n";
$description = array(1=>'Bbcode',2=>'Shortcode',3=>'Wrapper');
$style = array(1 => 'label-info', 2=>'label-primary', 3=>'label-warning');
foreach($this -> scbbcodes as $codes)
{
$type = $codes['type'];
$text .= "<tr>
<td class='forumheader3' style='width: 10%;'>".($codes['type'] == 1 ? "BBCode" : "Shortcode")."</td>
<td class='forumheader3' style='width: 10%;'><span class='label ".$style[$type]."'>".($description[$type])."</span></td>
<td class='forumheader3' style='width: auto;'>".(isset($codes['code']) ? $codes['code'] : "&nbsp;")."</td>
<td class='forumheader3' style='width: auto;'>".($codes['parm'] ? $codes['parm'] : "&nbsp;")."</td>
<td class='forumheader3' style='width: 40%;'>".($codes['details'] ? $codes['details'] : "&nbsp;")."</td>

View File

@@ -80,6 +80,8 @@ class e_parse_shortcode
* @var array
*/
protected $wrappers = array();
protected $wrapper = null; // current wrapper being processed.
protected $wrapperDebugDone = false;
/**
* Former $sc_style global variable. Internally used - performance reasons
@@ -754,7 +756,7 @@ class e_parse_shortcode
$this->addedCodes = &$extraCodes;
// TEMPLATEID_WRAPPER support - see contact template
// must be registered in e_shortcode object (batch) via wrapper() method before parsing
// must be registered in e_shortcode object (batch) via () method before parsing
// Do it only once per parsing cylcle and not on every doCode() loop - performance
if(method_exists($this->addedCodes, 'wrapper'))
{
@@ -764,6 +766,8 @@ class e_parse_shortcode
if(!empty($tmpWrap)) // FIX for #3 above.
{
$this->wrappers = array_merge($this->wrappers,$tmpWrap);
$this->wrapper = $this->addedCodes->getWrapperID();
}
}
@@ -1092,7 +1096,22 @@ class e_parse_shortcode
}
}
if(E107_DBG_BBSC && $this->wrapperDebugDone==false && !empty($this->wrappers))
{
list($wrapTmpl, $wrapID1, $wrapID2) = explode('/',$this->wrapper,3);
$wrapActive = strtoupper($wrapTmpl)."_WRAPPER['".$wrapID1."']";
if(!empty($wrapID2))
{
$wrapActive .= "['".$wrapID2."']";
}
// e107::getMessage()->addDebug("Active Wrapper: \$".$wrapActive);
$this->wrapperDebugDone = true;
global $db_debug;
$db_debug->logCode(3, $this->wrapper,null, '<pre>To use, add to the '.$wrapTmpl.' template:<br />$'.$wrapActive.'[\'SHORTCODE_NAME\'] = "(html before){---}(html after)";</pre>');
}
if (isset($ret) && ($ret != '' || is_numeric($ret)))
{
@@ -1320,6 +1339,13 @@ class e_shortcode
return $this;
}
public function getWrapperID()
{
return $this->wrapper;
}
/**
* Set external array data to be used in the batch
* Use setVars() - preferred.

View File

@@ -103,6 +103,7 @@ class pageClass
public $pageOutput = array(); // Output storage - text and caption
protected $renderMode; // Page render mode to be used on view page
protected $templateID = null;
function __construct($debug=FALSE)
{
@@ -578,8 +579,8 @@ class pageClass
$this->template = e107::getCoreTemplate('page', 'default');
// $this->batch = e107::getScBatch('page',null,'cpage')->setVars(new e_vars($ret))->setScVar('page', array()); ///Upgraded to setVars() array. (not using '$this->page')
$this->batch = e107::getScBatch('page',null,'cpage')->setVars($this->page);
$this->batch = e107::getScBatch('page',null,'cpage')->setVars($this->page)->wrapper('page/'.$this->templateID);
define("e_PAGETITLE", $this->page['page_title']);
@@ -589,21 +590,27 @@ class pageClass
$this->page = $sql->fetch();
// setting override to true breaks default.
$this->template = e107::getCoreTemplate('page', vartrue($this->page['page_template'], 'default'), true, true);
// setting override to true breaks default.
$this->templateID = vartrue($this->page['page_template'], 'default');
$this->template = e107::getCoreTemplate('page', $this->templateID, true, true);
if(!$this->template)
{
// switch to default
$this->template = e107::getCoreTemplate('page', 'default', false, false);
$this->templateID = 'default';
}
if(empty($this->template))
{
$this->template = e107::getCoreTemplate('page', 'default');
$this->templateID = 'default';
}
$this->batch = e107::getScBatch('page',null,'cpage');
$this->batch->wrapper('page/'.$this->templateID );
$this->pageText = $this->page['page_text'];
@@ -804,7 +811,7 @@ class pageClass
public function renderPage($template, $vars = null)
{
if(null === $vars)
{
$ret = e107::getParser()->parseTemplate($template, true, $this->batch);