Skip to content

Commit

Permalink
refs #1749 : Context object now covers plugin-specific passing parame…
Browse files Browse the repository at this point in the history
…ters.

 - updated - default plugins (continued.)
  • Loading branch information
inureyes committed Feb 16, 2015
1 parent 6cdf765 commit 86e4602
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 386 deletions.
46 changes: 34 additions & 12 deletions interface/owner/plugin/adminHandler/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,69 @@
require ROOT . '/library/preprocessor.php';
requireStrictRoute();
$context = Model_Context::getInstance();
if ((isset($_REQUEST['name'])) && (isset($adminHandlerMappings[$_REQUEST['name']])))
if ((isset($_REQUEST['name'])) && (isset($adminHandlerMappings[$_REQUEST['name']])))
{
$IV = array (
'REQUEST' => array(
'name' => array('string')
)
);

foreach($adminHandlerMappings[$_GET['name']]['params'] as $param) {
$ivItem = array ( $param['type']);
if (isset($param['default']) && !is_null($param['default']) ) $ivItem['default'] = $param['default'];
if (isset($param['mandatory']) && !is_null($param['mandatory']) ) $ivItem['mandatory'] = $param['mandatory'];

$IV['REQUEST'][$param['name']] = $ivItem;
}

if (Validator::validate($IV)) {
$plugin = $adminHandlerMappings[$_REQUEST['name']]['plugin'];
$handler = $adminHandlerMappings[$_REQUEST['name']]['handler'];

$pluginAccessURL = $context->getProperty('uri.blog') . '/owner/plugin/adminMenu?name=' . $plugin;
$pluginMenuURL = 'invalid link';
$pluginHandlerURL = $context->getProperty('uri.blog') . '/owner/plugin/adminHandler?name=' . $plugin;
$pluginSelfURL = $context->getProperty('uri.blog') . '/owner/plugin/adminHandler?name=' . $plugin . '/' . $handler;

$pluginAccessParam = '?name=' . $plugin;
$pluginSelfParam = '?name=' . $plugin . '/' . $handler;

$pluginURL = "{$context->getProperty('service.path')}/plugins/{$plugin}";
$pluginPath = ROOT . "/plugins/{$plugin}";
$pluginName = $plugin;

$context->setProperty('plugin.uri.access',$pluginAccessURL);
$context->setProperty('plugin.uri.menu',$pluginMenuURL);
$context->setProperty('plugin.uri.handler',$pluginHandlerURL);
$context->setProperty('plugin.uri.self',$pluginSelfURL);
$context->setProperty('plugin.parameter.access',$pluginAccessParam);
$context->setProperty('plugin.parameter.self',$pluginSelfParam);

$context->setProperty('plugin.uri',$context->getProperty('service.path')."/plugins/{$plugin}");
$context->setProperty('plugin.path',ROOT . "/plugins/{$plugin}");
$context->setProperty('plugin.name',$plugin);


$pluginURL = $context->getProperty('plugin.uri');
$pluginPath = $context->getProperty('plugin.path');
$pluginName = $context->getProperty('plugin.name');

include_once (ROOT . "/plugins/{$plugin}/index.php");
if (function_exists($handler)) {
if( !empty( $configMappings[$plugin]['config'] ) )
if( !empty( $configMappings[$plugin]['config'] ) )
$configVal = getCurrentSetting($plugin);
else
$configVal ='';

call_user_func($handler);
}
$context->unsetProperty('plugin.uri');
$context->unsetProperty('plugin.path');
$context->unsetProperty('plugin.name');
$context->unsetProperty('plugin.uri.access');
$context->unsetProperty('plugin.uri.menu');
$context->unsetProperty('plugin.uri.handler');
$context->unsetProperty('plugin.uri.self');
$context->unsetProperty('plugin.parameter.access');
$context->unsetProperty('plugin.parameter.self');

}
}

Expand Down
46 changes: 33 additions & 13 deletions interface/owner/plugin/adminMenu/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
require ROOT . '/library/preprocessor.php';
require ROOT . '/interface/common/owner/header.php';

if ((isset($_REQUEST['name'])) && (isset($adminMenuMappings[$_REQUEST['name']])))
if ((isset($_REQUEST['name'])) && (isset($adminMenuMappings[$_REQUEST['name']])))
{

$IV = array (
'REQUEST' => array(
'name' => array('string')
)
);

foreach($adminMenuMappings[$_REQUEST['name']]['params'] as $param) {
$ivItem = array ( $param['type']);
if (isset($param['default']) && !is_null($param['default']) ) $ivItem['default'] = $param['default'];
if (isset($param['mandatory']) && !is_null($param['mandatory']) ) $ivItem['mandatory'] = $param['mandatory'];

$IV['REQUEST'][$param['name']] = $ivItem;
}

if (Validator::validate($IV)) {
$_GET = $_POST = $_REQUEST;
$context = Model_Context::getInstance();
$_GET = $_POST = $_REQUEST;
$plugin = $adminMenuMappings[$_REQUEST['name']]['plugin'];
$handler = $adminMenuMappings[$_REQUEST['name']]['handler'];

Expand All @@ -35,10 +36,20 @@

$pluginAccessParam = '?name=' . $plugin;
$pluginSelfParam = '?name=' . $plugin . '/' . $handler;

$pluginURL = "{$context->getProperty('service.path')}/plugins/{$plugin}";
$pluginPath = ROOT . "/plugins/{$plugin}";
$pluginName = $plugin;

$context->setProperty('plugin.uri.access',$pluginAccessURL);
$context->setProperty('plugin.uri.menu',$pluginMenuURL);
$context->setProperty('plugin.uri.handler',$pluginHandlerURL);
$context->setProperty('plugin.uri.self',$pluginSelfURL);
$context->setProperty('plugin.parameter.access',$pluginAccessParam);
$context->setProperty('plugin.parameter.self',$pluginSelfParam);
$context->setProperty('plugin.uri',$context->getProperty('service.path')."/plugins/{$plugin}");
$context->setProperty('plugin.path',ROOT . "/plugins/{$plugin}");
$context->setProperty('plugin.name',$plugin);

$pluginURL = $context->getProperty('plugin.uri');
$pluginPath = $context->getProperty('plugin.path');
$pluginName = $context->getProperty('plugin.name');

// Loading locale resource
$languageDomain = null;
Expand All @@ -50,17 +61,26 @@
$locale->set($locale->defaultLanguage, $pluginName);
$locale->domain = $pluginName;
}
}
}
include_once (ROOT . "/plugins/{$plugin}/index.php");
if (function_exists($handler)) {
if( !empty( $configMappings[$plugin]['config'] ) )
if( !empty( $configMappings[$plugin]['config'] ) )
$configVal = getCurrentSetting($plugin);
else
$configVal ='';
call_user_func($handler);
}
/// unload.
if(!is_null($languageDomain)) $locale->domain = $languageDomain;
if(!is_null($languageDomain)) $locale->domain = $languageDomain;
$context->unsetProperty('plugin.uri');
$context->unsetProperty('plugin.path');
$context->unsetProperty('plugin.name');
$context->unsetProperty('plugin.uri.access');
$context->unsetProperty('plugin.uri.menu');
$context->unsetProperty('plugin.uri.handler');
$context->unsetProperty('plugin.uri.self');
$context->unsetProperty('plugin.parameter.access');
$context->unsetProperty('plugin.parameter.self');
}
}
require ROOT . '/interface/common/owner/footer.php';
Expand Down
5 changes: 1 addition & 4 deletions plugins/PN_Visitor_Default/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
*/
function PN_Visitor_Default()
{
global $pluginMenuURL, $pluginAccessURL, $pluginHandlerURL;
global $pluginMenuURL, $pluginHandlerURL;
$blogid = getBlogId();
requireComponent( "Textcube.Model.Statistics");
requireComponent('Textcube.Function.misc');
$stats = Statistics::getStatistics($blogid);
$date = isset($_GET['date']) ? $_GET['date'] : date('Ym', strtotime("now"));
?>
Expand Down Expand Up @@ -163,7 +161,6 @@ function execLoadFunction() {
function PN_Visitor_Default_set()
{
$blogid = getBlogId();
requireComponent( "Textcube.Model.Statistics");
$isAjaxRequest = isset($_REQUEST['ajaxcall']) ? true : false;
if ($isAjaxRequest) {
$result = Statistics::setTotalStatistics($blogid) ? 0 : -1;
Expand Down
7 changes: 3 additions & 4 deletions plugins/StatGraph/index.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php
// Statistics Graph by Gendoh http://gendoh.com
// if installed at other directory, edit a location of count
// global $pluginURL;

function DisplayStatisticsGraph($target)
{
global $pluginURL, $owner;
$target = '<div style="overflow:hidden; width:100%; text-align:center" ><img src="' . $pluginURL . '/count/count.php?blogid=' . getBlogId() . '" alt="Statistics Graph" title="Blog Visitors" /></div>';
{
$context = Model_Context::getInstance();
$target = '<div style="overflow:hidden; width:100%; text-align:center" ><img src="' . $context->getProperty('plugin.uri','') . '/count/count.php?blogid=' . getBlogId() . '" alt="Statistics Graph" title="Blog Visitors" /></div>';
return $target;
}
?>
6 changes: 4 additions & 2 deletions plugins/StatGraph/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
<plugin version="1.0">
<title>Graphic Statistics</title>
<link>http://gendoh.com</link>
<version>0.97</version>
<version>0.98</version>
<description>
접속자 통계를 Graph로 표시합니다. [##_StatisticsGraph_##] 태그를 스킨에 삽입하거나 사이드바에서 추가하면 됩니다.
</description>
<license>GPL</license>
<author link="http://gendoh.com"><![CDATA[겐도]]></author>
<safety changeData="no" exposeData="no" accessLocal="no" accessRemote="no" accessRaw="no" />
<requirements>
<textcube>1.8</textcube>
<textcube>
<minVersion>1.10.3</minVersion>
</textcube>
</requirements>
<binding>
<tag name="StatisticsGraph" handler="DisplayStatisticsGraph" />
Expand Down
1 change: 0 additions & 1 deletion plugins/URLkeeper/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

function URLkeeper($target)
{
global $hostURL, $blogURL;
global $configVal;
requireComponent('Tattertools.Function.misc');
$data = Setting::fetchConfigVal( $configVal);
Expand Down
Loading

0 comments on commit 86e4602

Please # to comment.