Skip to content
Browse files

Module Includer and Controller

  • Loading branch information...
1 parent 4ff7ade commit 38ed3edea290a3faa536c72d42af45f08dec6f7e Amy Stephen committed May 17, 2012
View
11 source/Molajo/Configuration/Include/ModuleModel.xml
@@ -0,0 +1,11 @@
+<model
+ name="ExtensionInstance"
+ catalog_type_id="1350"
+ table="#__extension_instances"
+ primary_key="id"
+ primary_prefix="a"
+ get_customfields="1"
+ get_item_children="0"
+ use_special_joins="0"
+ check_view_level_access="1"
+ data_source="JDatabase"/>
View
22 source/Molajo/Configuration/Include/ModuleParameters.xml
@@ -1,15 +1,15 @@
-<field name="display_title" type="char" null="1" default="" values=""/>
+ <field name="display_title" type="char" null="1" default="" values=""/>
-<field name="display_view_on_no_results" type="binary" null="1" default="1" values="0,1"/>
+ <field name="display_view_on_no_results" type="binary" null="1" default="1" values="0,1"/>
-<field name="template_view_id" type="integer" null="1" default="" values=""/>
-<field name="template_view_css_id" type="char" null="1" default="" values=""/>
-<field name="template_view_css_class" type="char" null="1" default="" values=""/>
+ <field name="template_view_id" type="integer" null="1" default="" values=""/>
+ <field name="template_view_css_id" type="char" null="1" default="" values=""/>
+ <field name="template_view_css_class" type="char" null="1" default="" values=""/>
-<field name="wrap_view_id" type="integer" null="1" default="" values=""/>
-<field name="wrap_view_css_id" type="char" null="1" default="" values=""/>
-<field name="wrap_view_css_class" type="char" null="1" default="" values=""/>
+ <field name="wrap_view_id" type="integer" null="1" default="" values=""/>
+ <field name="wrap_view_css_id" type="char" null="1" default="" values=""/>
+ <field name="wrap_view_css_class" type="char" null="1" default="" values=""/>
-<field name="caching" type="binary" null="1" default="1" values="0,1"/>
-<field name="cache_time" type="integer" null="1" default="15" values=""/>
-<field name="cache_handler" type="char" null="1" default="" values=""/>
+ <field name="caching" type="binary" null="1" default="1" values="0,1"/>
+ <field name="cache_time" type="integer" null="1" default="15" values=""/>
+ <field name="cache_handler" type="char" null="1" default="" values=""/>
View
42 source/Molajo/Configuration/Include/b.json
@@ -1,33 +1,42 @@
{
"1":{
- "display_title":"Molajo Article Component: Site Page Header",
+ "site_name":"Molajo",
+ "link":"http://Molajo.org",
+ "linked_text":"Molajo &reg;",
+ "remaining_text":"is Free Software",
- "display_view_on_no_results":"1",
+ "display_title":"Molajo Article Component: Site Page Footer",
- "template_view_id":"41",
- "template_view_css_id":"",
- "template_view_css_class":"",
+ "display_view_on_no_results":"1",
- "wrap_view_id":"61",
- "wrap_view_css_id":"",
- "wrap_view_css_class":"",
+ "template_view_id":"42",
+ "template_view_css_id":"",
+ "template_view_css_class":"",
+
+ "wrap_view_id":"62",
+ "wrap_view_css_id":"",
+ "wrap_view_css_class":"",
- "caching":"0",
- "cache_time":"15",
- "cache_handler":"file"
+ "caching":"0",
+ "cache_time":"15",
+ "cache_handler":"file"
},
"2":{
+ "site_name":"Molajo",
+ "link":"http://Molajo.org",
+ "linked_text":"Molajo &reg;",
+ "remaining_text":"is Free Software",
- "display_title":"Molajo Article Component: Administrator Page Header",
+ "display_title":"Molajo Article Component: Administrator Page Footer",
"display_view_on_no_results":"1",
- "template_view_id":"41",
+ "template_view_id":"42",
"template_view_css_id":"",
"template_view_css_class":"",
- "wrap_view_id":"61",
+ "wrap_view_id":"62",
"wrap_view_css_id":"",
"wrap_view_css_class":"",
@@ -39,3 +48,8 @@
}
+
+"site_name":"Molajo",
+"link":"http://Molajo.org",
+"linked_text":"Molajo &reg;",
+"remaining_text":"is Free Software",
View
160 source/Molajo/Extension/Helper/ExtensionHelper.php
@@ -152,24 +152,16 @@ public function getIncludeExtension($extension_id, $model_name = null, $type = n
$customFieldName = ucfirst(strtolower($customFieldName));
- if ('Extensioninstances' . $customFieldName == 'Extensioninstances' . 'Parameters') {
+ if ($customFieldName == 'Parameters') {
Services::Registry()->merge(
- 'Extensioninstances' . $customFieldName,
- 'Parameters'
+ $row['table_registry_name'].'Parameters', 'Parameters'
);
}
- if ('Extensioninstances' . $customFieldName == 'Extensioninstances' . 'Metadata') {
- Services::Registry()->merge(
- 'Extensioninstances' . $customFieldName,
- 'Metadata'
- );
- }
+ Services::Registry()->deleteRegistry($row['table_registry_name'] . $customFieldName);
- Services::Registry()->deleteRegistry('Extensioninstances' . $customFieldName);
}
- echo '<pre>';
- var_dump(Services::Registry()->get('Parameters'));
+
return;
}
@@ -193,8 +185,6 @@ public function get($extension_id = 0, $model = null, $type = null)
$m = Application::Controller()->connect($model, $type);
- $m->model->set('id', (int)$extension_id);
-
/**
* a. Extensions Instances Table
*/
@@ -388,18 +378,25 @@ public function getPathURL($catalog_type_id, $name)
public function loadLanguage($path = null)
{
if ($path == null) {
- $path = Services::Registry()->get('Extension', 'path');
+ $path = Services::Registry()->get('Include', 'extension_path');
}
- $path .= '/language';
+ if ($path == null) {
+ $path = Services::Registry()->get('Request', 'extension_path');
+ }
+ $path .= '/Language';
if (Services::Filesystem()->folderExists($path)) {
} else {
+ return;
echo 'does not exist'.$path.'<br />';
+ echo '<pre>';
+ var_dump(Services::Registry()->get('Include'));
return false;
}
- Services::Language()->load($path, Services::Language()->get('tag'), false, false);
+//todo fix Services::Language()->load($path, Services::Language()->get('tag'), false, false);
+ Services::Language()->load($path, 'en-GB', false, false);
return true;
}
@@ -412,45 +409,126 @@ public function loadLanguage($path = null)
*/
public function finalizeParameters($source_id = 0, $action = 'display')
{
+
+ $getTemplate = true;
+
+ $template_view_id = (int) Services::Registry()->get('Parameters', 'template_view_id', 0);
+ $template_view_title = Services::Registry()->get('Parameters', 'template_view_title', '');
+
+ if ($template_view_id == 0) {
+ } else {
+ $template_view_title = Helpers::Extension()->getInstanceTitle((int)$template_view_id);
+ if ($template_view_title == false) {
+ } else {
+ $getTemplate = false;
+ Services::Registry()->set('Parameters', 'wrap_view_title', $template_view_title);
+ }
+
+ }
+
+ if ($template_view_title == '') {
+ } else {
+ if ($template_view_id == 0) {
+ $template_view_id = Helpers::Extension()->getInstanceID(
+ CATALOG_TYPE_EXTENSION_TEMPLATE_VIEW,
+ $template_view_title
+ );
+ if ($template_view_id == false) {
+ } else {
+ $getTemplate = false;
+ Services::Registry()->set('Parameters', 'template_view_id', $template_view_id);
+ }
+ }
+ }
+
+
+ $getWrap = true;
+
+ $wrap_view_id = (int) Services::Registry()->get('Parameters', 'wrap_view_id', 0);
+ $wrap_view_title = Services::Registry()->get('Parameters', 'wrap_view_title', '');
+
+ if ($wrap_view_id == 0) {
+ } else {
+ $wrap_view_title = Helpers::Extension()->getInstanceTitle((int)$wrap_view_id);
+ if ($wrap_view_title == false) {
+ } else {
+ $getWrap = false;
+ Services::Registry()->set('Parameters', 'wrap_view_title', $wrap_view_title);
+ }
+
+ }
+
+ if ($wrap_view_title == '') {
+ } else {
+ if ($wrap_view_id == 0) {
+ $wrap_view_id = Helpers::Extension()->getInstanceID(
+ CATALOG_TYPE_EXTENSION_TEMPLATE_VIEW,
+ $wrap_view_title
+ );
+ if ($wrap_view_id == false) {
+ } else {
+ $getWrap = false;
+ Services::Registry()->set('Parameters', 'wrap_view_id', $wrap_view_id);
+ }
+ }
+ }
+
+
if ($action == 'add' || $action == 'edit') {
Services::Registry()->set('Parameters', 'template_view', 'form');
- Services::Registry()->set('Parameters', 'template_view_id',
- Services::Registry()->get('Parameters', 'form_template_view_id'));
- Services::Registry()->set('Parameters', 'template_view_css_id',
- Services::Registry()->get('Parameters', 'form_template_view_css_id'));
- Services::Registry()->set('Parameters', 'template_view_css_class',
- Services::Registry()->get('Parameters', 'form_template_view_css_class'));
+ if ($getTemplate == true) {
+ Services::Registry()->set('Parameters', 'template_view_id',
+ Services::Registry()->get('Parameters', 'form_template_view_id'));
+ Services::Registry()->set('Parameters', 'template_view_css_id',
+ Services::Registry()->get('Parameters', 'form_template_view_css_id'));
+ Services::Registry()->set('Parameters', 'template_view_css_class',
+ Services::Registry()->get('Parameters', 'form_template_view_css_class'));
+ }
- Services::Registry()->set('Parameters', 'wrap_view_id',
- Services::Registry()->get('Parameters', 'form_wrap_view_id'));
- Services::Registry()->set('Parameters', 'wrap_view_css_id',
- Services::Registry()->get('Parameters', 'form_wrap_view_css_id'));
- Services::Registry()->set('Parameters', 'wrap_view_css_class',
- Services::Registry()->get('Parameters', 'form_wrap_view_css_class'));
+ if ($getWrap == true) {
+ Services::Registry()->set('Parameters', 'wrap_view_id',
+ Services::Registry()->get('Parameters', 'form_wrap_view_id'));
+ Services::Registry()->set('Parameters', 'wrap_view_css_id',
+ Services::Registry()->get('Parameters', 'form_wrap_view_css_id'));
+ Services::Registry()->set('Parameters', 'wrap_view_css_class',
+ Services::Registry()->get('Parameters', 'form_wrap_view_css_class'));
+ }
} else if ((int)$source_id == 0) {
Services::Registry()->set('Parameters', 'template_view', 'list');
- Services::Registry()->set('Parameters', 'template_view_id',
- Services::Registry()->get('Parameters', 'list_template_view_id'));
- Services::Registry()->set('Parameters', 'template_view_css_id',
- Services::Registry()->get('Parameters', 'list_template_view_css_id'));
- Services::Registry()->set('Parameters', 'template_view_css_class',
- Services::Registry()->get('Parameters', 'list_template_view_css_class'));
+ if ($getTemplate == true) {
+ Services::Registry()->set('Parameters', 'template_view_id',
+ Services::Registry()->get('Parameters', 'list_template_view_id'));
+ Services::Registry()->set('Parameters', 'template_view_css_id',
+ Services::Registry()->get('Parameters', 'list_template_view_css_id'));
+ Services::Registry()->set('Parameters', 'template_view_css_class',
+ Services::Registry()->get('Parameters', 'list_template_view_css_class'));
+ }
+
+ if ($getWrap == true) {
+ Services::Registry()->set('Parameters', 'wrap_view_id',
+ Services::Registry()->get('Parameters', 'list_wrap_view_id'));
+ Services::Registry()->set('Parameters', 'wrap_view_css_id',
+ Services::Registry()->get('Parameters', 'list_wrap_view_css_id'));
+ Services::Registry()->set('Parameters', 'wrap_view_css_class',
+ Services::Registry()->get('Parameters', 'list_wrap_view_css_class'));
+ }
- Services::Registry()->set('Parameters', 'wrap_view_id',
- Services::Registry()->get('Parameters', 'list_wrap_view_id'));
- Services::Registry()->set('Parameters', 'wrap_view_css_id',
- Services::Registry()->get('Parameters', 'list_wrap_view_css_id'));
- Services::Registry()->set('Parameters', 'wrap_view_css_class',
- Services::Registry()->get('Parameters', 'list_wrap_view_css_class'));
} else {
Services::Registry()->set('Parameters', 'template_view', 'item');
+ if ($getTemplate == true) {
+
+ }
+
+ if ($getWrap == true) {
+
+ }
}
Helpers::TemplateView()->get();
View
12 source/Molajo/Extension/Includer.php
@@ -184,7 +184,6 @@ public function process($attributes = array())
return $this->rendered_output;
}
-
/**
* getAttributes
*
@@ -226,7 +225,6 @@ protected function getAttributes()
} else if ($name == 'wrap_view_css_class') {
Services::Registry()->set('Parameters', 'wrap_view_css_id', $value);
}
-
}
}
}
@@ -247,6 +245,14 @@ protected function getExtension($extension_id = null)
$this->type
);
+ echo '<br /><br /><pre>';
+ var_dump(Services::Registry()->get('Parameters'));
+ echo '</pre>';
+
+ echo '<br /><br /><pre>';
+ var_dump(Services::Registry()->get('Include'));
+ echo '</pre>';
+
if ($results == false) {
return Services::Registry()->set('Parameter', 'status_found', false);
}
@@ -266,8 +272,6 @@ protected function getExtension($extension_id = null)
*/
public function setRenderCriteria()
{
- //add user?
-
/** Final Template and Wrap selections */
Services::Registry()->merge('Configuration', 'Parameters', true);
View
21 source/Molajo/Extension/Module/PageFooter/manifest.xml
@@ -10,18 +10,13 @@
<version>1.0</version>
<description>MODULE_PAGE_FOOTER_DESCRIPTION</description>
<config>
- <field name="parameters">
- <element name="display_view_on_no_results" filter="binary" null="1" default="1" values="0,1"/>
- <element name="template_view_id" filter="integer" null="1" default="42" values=""/>
- <element name="wrap_view_id" filter="integer" null="1" default="62" values=""/>
- <element name="site_name" filter="char" null="0" default="Molajo" values=""/>
- <element name="link" filter="char" null="1" default="http://Molajo.org" values=""/>
- <element name="linked_text" filter="char" null="0" default="none" values=""/>
- <element name="remaining_text" filter="char" null="0" default="Molajo" values=""/>
- <element name="query_object" filter="char" null="0" default="none" values=""/>
- <element name="caching" filter="binary" null="1" default="1" values="0,1"/>
- <element name="cache_time" filter="integer" null="1" default="15" values=""/>
- <element name="cache_handler" filter="char" null="1" default="file" values=""/>
- </field>
+ <include model="ModuleModel"/>
+ <parameters>
+ <field name="site_name" type="char" null="0" default="Molajo" values=""/>
+ <field name="link" type="char" null="1" default="http://Molajo.org" values=""/>
+ <field name="linked_text" type="char" null="0" default="Molajo" values=""/>
+ <field name="remaining_text" type="char" null="0" default=" is Free Software" values=""/>
+ <include parameters="ModuleParameters"/>
+ </parameters>
</config>
</extension>
View
5 source/Molajo/Extension/Module/PageHeader/manifest.xml
@@ -10,6 +10,9 @@
<version>1.0</version>
<description>MODULE_PAGE_HEADER_DESCRIPTION</description>
<config>
- <include name="ModuleParameters"/>
+ <include model="ModuleModel"/>
+ <parameters>
+ <include parameters="ModuleParameters"/>
+ </parameters>
</config>
</extension>
View
12 source/Molajo/Extension/Theme/Bootstrap/View/Page/Default/index.php
@@ -6,13 +6,11 @@
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
* <include:module name=Mainmenu wrap=Nav />
* <include:module name=Sidebar template=Sidebar wrap=div/>
+ *<include:defer/>
+ * <include:message/>
+ * <include:head/>
*/
defined('MOLAJO') or die; ?>
-<include:module name=Pageheader template=Pageheader wrap=Head/>
-<include:message/>
-
-<include:head/>
-
+<include:module name=Pageheader/>
<include:request/>
-<include:module name=Pagefooter template=Pagefooter wrap=Footer/>
-<include:defer/>
+<include:module name=Pagefooter/>
View
1 source/Molajo/Extension/View/Template/PageHeader/View/Custom.php
@@ -8,4 +8,5 @@
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/
defined('MOLAJO') or die; ?>
+in here.
<h1><?php echo Services::Registry()->get('Configuration', 'site_title', 'Molajo'); ?></h1>
View
2 source/Molajo/Extension/View/Template/PageHeader/manifest.xml
@@ -10,7 +10,5 @@
<version>1.0</version>
<description>VIEW_TEMPLATE_PAGE_HEADER_DESCRIPTION</description>
<config>
- <field name="parameters" registry="TemplateViewParameters">
- </field>
</config>
</extension>
View
3 source/Molajo/MVC/Controller/DisplayController.php
@@ -125,7 +125,8 @@ public function display()
$this->view_path_url = Services::Registry()->get('Parameters', 'template_view_path_url');
$renderedOutput = $this->renderView(Services::Registry()->get('Parameters', 'template_view_title'));
-
+echo '<br /><br /><br /><br />';
+echo $renderedOutput;
/** Mustache */
if (Services::Registry()->get('Parameters', 'mustache', 1) == 1) {
$renderedOutput = $this->processRenderedOutput($renderedOutput);
View
6 source/Molajo/MVC/Controller/EntryController.php
@@ -123,11 +123,7 @@ public function connect($table = '', $type = null)
$this->model->set('id_name', Services::Registry()->get($this->table_registry_name, 'id_name'));
/** 4. Set DB Properties */
- if (strtolower($type) == 'module') {
- $dbo = 'JDatabase';
- } else {
- $dbo = Services::Registry()->get($this->table_registry_name, 'data_source');
- }
+ $dbo = Services::Registry()->get($this->table_registry_name, 'data_source');
$this->model->set('db', Services::$dbo()->get('db'));
$this->model->set('query', Services::$dbo()->getQuery());
View
104 source/Molajo/Service/Services/Configuration/ConfigurationService.php
@@ -359,27 +359,38 @@ public static function processModuleTable($file, $type = 'Module', $path_and_fil
return $registryName;
}
- Services::Registry()->set($registryName, 'model_name', $file);
- Services::Registry()->set($registryName, 'table_name', '#__extension_instances');
- Services::Registry()->set($registryName, 'primary_key', 'id');
- Services::Registry()->set($registryName, 'primary_prefix', 'a');
- Services::Registry()->set($registryName, 'name_key', 'title');
- Services::Registry()->set($registryName, 'get_customfields', true);
- Services::Registry()->set($registryName, 'get_item_children', false);
- Services::Registry()->set($registryName, 'use_special_joins', false);
- Services::Registry()->set($registryName, 'check_view_level_access', false);
- Services::Registry()->set($registryName, 'data_source', 'JDatabase');
+ /** Model */
+ if (isset($xml->config->include['model'])) {
+
+ $include = (string)$xml->config->include['model'];
+
+ if ($xml_string == '') {
+ $xml_string = file_get_contents($path_and_file);
+ }
+
+ $replace_this = '<include model="' . $include . '"/>';
+
+ $xml_string = ConfigurationService::replaceIncludeStatement(
+ $include, $file, $replace_this, $xml_string
+ );
+
+ $xml = simplexml_load_string($xml_string);
+ }
+
+ /** Set Model Properties */
+ ConfigurationService::setModelRegistry($registryName, $xml->config->model);
+ Services::Registry()->set($registryName, 'model_name', $registryName);
/** Parameters - Include Code */
- if (isset($xml->config->include['name'])) {
+ if (isset($xml->config->parameters->include['parameters'])) {
- $include = (string)$xml->config->include['name'];
+ $include = (string)$xml->config->parameters->include['parameters'];
if ($xml_string == '') {
$xml_string = file_get_contents($path_and_file);
}
- $replace_this = '<include name="' . $include . '"/>';
+ $replace_this = '<include parameters="' . $include . '"/>';
$xml_string = ConfigurationService::replaceIncludeStatement(
$include, $file, $replace_this, $xml_string
@@ -394,7 +405,7 @@ public static function processModuleTable($file, $type = 'Module', $path_and_fil
/** Retrieve Field Attributes for each field */
$fieldArray = array();
- foreach ($xml->config->field as $key1 => $value1) {
+ foreach ($xml->config->parameters->field as $key1 => $value1) {
$attributes = get_object_vars($value1);
$fieldAttributes = ($attributes["@attributes"]);
@@ -406,7 +417,6 @@ public static function processModuleTable($file, $type = 'Module', $path_and_fil
} else {
echo 'Field attribute not known ' . $key2 . ':' . $value2 . ' for ' . $file . '<br />';
}
-
$fieldAttributesArray[$key2] = $value2;
}
@@ -415,37 +425,13 @@ public static function processModuleTable($file, $type = 'Module', $path_and_fil
Services::Registry()->set($registryName, 'Parameters', $fieldArray);
+ Services::Registry()->set($registryName, 'CustomFieldGroups', array('Parameters'));
+
return $registryName;
}
- /**
- * processTableFile extracts XML configuration data for Tables/Models and populates Registry
- * Returns the name of the registry
- *
- * @static
- * @param $file
- * @param string $type
- * @param $path_and_file
- * @param $xml
- *
- * @return string
- * @since 1.0
- * @throws \RuntimeException
- */
- public static function processTableFile($file, $type = 'Table', $path_and_file, $xml)
+ public static function setModelRegistry($registryName, $xml)
{
- /** Table only: Process Include Code */
- $xml_string = '';
-
- $registryName = ucfirst(strtolower($file)) . $type;
-
-//echo 'In processTableFile creating Registry: ' . $registryName . ' for file: ' . $path_and_file . '<br />';
-
- $exists = Services::Registry()->exists($registryName);
- if ($exists === true) {
- return $registryName;
- }
-
Services::Registry()->set($registryName, 'model_name', (string)$xml['name']);
Services::Registry()->set($registryName, 'table_name', (string)$xml['table']);
@@ -501,6 +487,40 @@ public static function processTableFile($file, $type = 'Table', $path_and_file,
}
Services::Registry()->set($registryName, 'data_source', $value, 'JDatabase');
+ return;
+ }
+
+ /**
+ * processTableFile extracts XML configuration data for Tables/Models and populates Registry
+ * Returns the name of the registry
+ *
+ * @static
+ * @param $file
+ * @param string $type
+ * @param $path_and_file
+ * @param $xml
+ *
+ * @return string
+ * @since 1.0
+ * @throws \RuntimeException
+ */
+ public static function processTableFile($file, $type = 'Table', $path_and_file, $xml)
+ {
+ /** Table only: Process Include Code */
+ $xml_string = '';
+
+ $registryName = ucfirst(strtolower($file)) . $type;
+
+//echo 'In processTableFile creating Registry: ' . $registryName . ' for file: ' . $path_and_file . '<br />';
+
+ $exists = Services::Registry()->exists($registryName);
+ if ($exists === true) {
+ return $registryName;
+ }
+
+ /** Set Model Properties */
+ ConfigurationService::setModelRegistry($registryName, $xml);
+
/** Body - No registry */
$include = '';
View
6 source/Molajo/Service/Services/Language/LanguageService.php
@@ -205,9 +205,9 @@ protected function load_core_files()
public function load($path)
{
$loaded = $this->loadLanguage($path, $this->language . '.ini');
- if ($loaded === false) {
- Services::Debug()->set('LanguageServices: cannot load file: '
- . $path . '/' . $this->language . '.ini');
+ if ($loaded == false) {
+// Services::Debug()->set('LanguageServices: cannot load file: '
+ echo 'cannot load language file ' . $path . '/' . $this->language . '.ini';
} else {
return true;
}

0 comments on commit 38ed3ed

Please sign in to comment.
Something went wrong with that request. Please try again.