@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="SitesListbox"
name="Sites"
table="#__sites"
primary_key="id"
name_key="name"
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="StickiedListbox"
name="Stickied"
data_source="Text">
</model>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="TemplatesviewListbox"
name="Templates"
table="#__extension_instances"
primary_key="id"
name_key="title"
@@ -20,17 +20,17 @@
</fields>
>
<joins>
<join table="#__extensions"
<join model="Extensions"
alias="extensions"
select=""
jointo="id"
joinwith="extension_id"/>
<join table="#__application_extension_instances"
<join model="ApplicationExtensionInstances"
alias="application_extension_instances"
select=""
jointo="extension_instance_id,application_id"
joinwith="id,APPLICATION_ID"/>
<join table="#__site_extension_instances"
<join model="SiteExtensionInstances"
alias="site_extension_instances"
select=""
jointo="extension_instance_id,site_id"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="ThemesListbox"
name="Themes"
table="#__extension_instances"
primary_key="id"
name_key="title"
@@ -21,17 +21,17 @@
</fields>
>
<joins>
<join table="#__extensions"
<join model="Extensions"
alias="extensions"
select=""
jointo="id"
joinwith="extension_id"/>
<join table="#__application_extension_instances"
<join model="ApplicationExtensionInstances"
alias="application_extension_instances"
select=""
jointo="extension_instance_id,application_id"
joinwith="id,APPLICATION_ID"/>
<join table="#__site_extension_instances"
<join model="SiteExtensionInstances"
alias="site_extension_instances"
select=""
jointo="extension_instance_id,site_id"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="WrapviewListbox"
name="Wraps"
table="#__extension_instances"
primary_key="id"
name_key="title"
@@ -20,17 +20,17 @@
</fields>
>
<joins>
<join table="#__extensions"
<join model="Extensions"
alias="extensions"
select=""
jointo="id"
joinwith="extension_id"/>
<join table="#__application_extension_instances"
<join model="ApplicationExtensionInstances"
alias="application_extension_instances"
select=""
jointo="extension_instance_id,application_id"
joinwith="id,APPLICATION_ID"/>
<join table="#__site_extension_instances"
<join model="SiteExtensionInstances"
alias="site_extension_instances"
select=""
jointo="extension_instance_id,site_id"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="CategoriesListbox"
name="Categories"
table="#__content"
primary_key="id"
name_key="title"
@@ -18,6 +18,8 @@
<field name="id" type="int" null="1" default="0" identity="1"/>
<field name="title" type="char" null="0" default="" unique="1"/>
</fields>
>
<triggers>
<trigger name="Publishedstatus"/>
</triggers>
</table>
</model>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="FriendsListbox"
name="GroupsListbox"
table="#__content"
primary_key="id"
name_key="title"
@@ -10,32 +10,14 @@
use_special_joins="1"
check_view_level_access="0"
process_triggers="0"
filter_catalog_type_id="130"
filter_check_published_status="1"
filter_catalog_type_id="130"
data_source="JDatabase">
<table>
<fields>
<field name="id" type="int" null="1" default="0" identity="1"/>
<field name="title" type="char" null="0" default="" unique="1"/>
</fields>
>
<joins>
<join table="#__extension_instances"
alias="extension_instances"
select=""
jointo="id"
joinwith="extension_instance_id"/>
<join table="#__application_extension_instances"
alias="application_extension_instances"
select=""
jointo="extension_instance_id,application_id"
joinwith="id,APPLICATION_ID"/>
<join table="#__site_extension_instances"
alias="site_extension_instances"
select=""
jointo="extension_instance_id,site_id"
joinwith="id,SITE_ID"/>
</joins>
<triggers>
<trigger name="Publishedstatus"/>
</triggers>
@@ -10,35 +10,16 @@
use_special_joins="1"
check_view_level_access="0"
process_triggers="0"
filter_catalog_type_id="100"
filter_check_published_status="1"
filter_catalog_type_id="100,110,120"
data_source="JDatabase">
<table>
<fields>
<field name="id" type="int" null="1" default="0" identity="1"/>
<field name="title" type="char" null="0" default="" unique="1"/>
</fields>
>
<joins>
<join table="#__extension_instances"
alias="extension_instances"
select=""
jointo="id"
joinwith="extension_instance_id"/>
<join table="#__application_extension_instances"
alias="application_extension_instances"
select=""
jointo="extension_instance_id,application_id"
joinwith="id,APPLICATION_ID"/>
<join table="#__site_extension_instances"
alias="site_extension_instances"
select=""
jointo="extension_instance_id,site_id"
joinwith="id,SITE_ID"/>
</joins>
<triggers>
<trigger name="Publishedstatus"/>
</triggers>
</table>
</model>

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="StatusListbox"
name="Status"
data_source="Text">
</model>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<model
name="TagsListbox"
name="Tags"
table="#__content"
primary_key="id"
name_key="title"
@@ -18,5 +18,8 @@
<field name="id" type="int" null="1" default="0" identity="1"/>
<field name="title" type="char" null="0" default="" unique="1"/>
</fields>
<triggers>
<trigger name="Publishedstatus"/>
</triggers>
</table>
</model>
@@ -50,7 +50,7 @@
<customfield name="parameters">

<field name="application_name" type="char" null="1" default="Molajo Application" values=""/>
<field name="application_home_catalog_id" type="integer" null="0" default="" values=""/>
<field name="application_home_catalog_id" type="catalog_id" null="0" default="" values=""/>
<field name="application_logon_requirement" type="binary" null="1" default="1" values="0,1"/>

<field name="url_sef" type="binary" null="1" default="1" values="0,1"/>
@@ -63,7 +63,6 @@
<field name="language_direction" type="char" null="1" default="ltr" values="ltr,rtl"/>
<field name="language_multilingual" type="binary" null="1" default="0" values="0,1"/>
<field name="language_utc_offset" type="char" null="1" default="UTC" values=""/>
<field name="language_utc_offset_user" type="char" null="1" default="UTC" values=""/>

<field name="debug" type="boolean" null="1" default="0" values=""/>
<field name="debug_log" type="text" null="0" default="echo"
@@ -12,7 +12,7 @@
<table>

<fields>
<field name="id" type="int" null="1" default="0"/>
<field name="id" type="catalog_id" null="1" default="0"/>
<field name="catalog_type_id" type="int" null="0" default="" values=""/>
<field name="source_id" type="int" null="0" default="" values=""/>
<field name="routable" type="boolean" null="0" default="0"/>
@@ -25,7 +25,7 @@
</fields>

<joins>
<join table="#__catalog_types" alias="b" select="title,source_table" jointo="id"
<join model="CatalogTypes" alias="b" select="title,source_table" jointo="id"
joinwith="catalog_type_id"/>
</joins>

@@ -13,7 +13,7 @@
<table>
<fields>
<field name="id" type="int" null="1" default="0"/>
<field name="catalog_id" type="int" null="0" default="" values=""/>
<field name="catalog_id" type="catalog_id" null="0" default="" values=""/>
<field name="user_id" type="int" null="0" default="0" values=""/>
<field name="rating" type="int" null="1" default="" values=""/>
<field name="activity_datetime" type="datetime" null="0" default=""/>
@@ -11,7 +11,7 @@
data_source="JDatabase">
<table>
<fields>
<field name="catalog_id" type="int" null="0" default=""/>
<field name="catalog_id" type="catalog_id" null="0" default=""/>
<field name="category_id" type="int" null="0" default=""/>
</fields>
<foreignkeys>
@@ -13,7 +13,7 @@
<fields>
<field name="id" type="int" null="0" default=""/>
<field name="group_id" type="int" null="0" default=""/>
<field name="catalog_id" type="int" null="0" default=""/>
<field name="catalog_id" type="catalog_id" null="0" default=""/>
<field name="action_id" type="int" null="0" default=""/>
</fields>
<foreignkeys>
@@ -14,26 +14,26 @@
<field name="id" type="" null="0" default="" identity="1"/>
<field name="user_id" type="int" null="0" default=""/>
<field name="action_id" type="int" null="0" default=""/>
<field name="catalog_id" type="int" null="0" default=""/>
<field name="catalog_id" type="catalog_id" null="0" default=""/>
<field name="activity_datetime" type="datetime" null="0" default=""/>
</fields>
<joins>
<join table="#__users"
<join model="Users"
alias="useractivity_to_users"
select="username,first_name,last_name"
jointo="id"
joinwith="user_id"/>
<join table="#__actions"
<join model="Actions"
alias="useractivity_to_actions"
select="title"
jointo="id"
joinwith="action_id"/>
<join table="#__catalog"
<join model="Catalog"
alias="useractivity_to_catalog"
select="catalog_type_id,source_id,sef_request,view_group_id"
jointo="id"
joinwith="catalog_id"/>
<join table="#__catalog_types"
<join model="CatalogTypes"
alias="useractivity_to_catalog_type"
select="title,source_table"
jointo="id"
@@ -8,7 +8,7 @@
<fields>
<field name="id" type="int" null="0" default=""/>
<field name="view_group_id" type="int" null="0" default=""/>
<field name="catalog_id" type="int" null="0" default=""/>
<field name="catalog_id" type="catalog_id" null="0" default=""/>
<field name="action_id" type="int" null="0" default=""/>
</fields>
<foreignkeys>

This file was deleted.

@@ -111,6 +111,9 @@ protected function loadMedia()
}
}

//todo figure out why the theme media is not loading
$this->loadMedia2();

/** Theme */
$priority = Services::Registry()->get('Parameters', 'asset_priority_theme', 600);
$file_path = Services::Registry()->get('Parameters', 'theme_path');
@@ -143,6 +146,115 @@ protected function loadMedia()
return;
}

/**
* loadMedia - automatically loaded in the Theme Rendering process
* Method can be used to load external media, special metadata or links
*
* http://coding.smashingmagazine.com/2012/01/16/resolution-independence-with-svg/
*
* http://24ways.org/2011/displaying-icons-with-fonts-and-data-attributes
*
* http://keyamoon.com/icomoon/#toHome
* adapt.js
* http://responsivepx.com/
* http://mattkersley.com/responsive/
* http://www.responsinator.com/
* http://quirktools.com/screenfly/
*
* @since 1.0
*/
public function loadMedia2()
{
/** Theme Folder */
$theme = Services::Registry()->get('Parameters', 'theme_path_node');

/** IE */
Services::Metadata()->set('X-UA-Compatible', 'IE=EmulateIE7; IE=EmulateIE9', 'http-equiv');

/** Mobile Specific Meta */
Services::Metadata()->set(
'viewport', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no', 'name'
);

/** Media Queries to load CSS */
Services::Asset()->addCss(
$url = EXTENSIONS_THEMES_URL . '/' . $theme . '/' . 'css/grid/base.css',
$priority=1000,
$mimetype='test/css',
$media='all',
$conditional='',
$attributes=array());

Services::Asset()->addCss(
$url=EXTENSIONS_THEMES_URL. '/' . $theme . '/' . 'css/grid/720_grid.css',
$priority=1000,
$mimetype='test/css',
$media='',
$conditional='lt IE 9',
$attributes=array());

Services::Asset()->addCss(
$url=EXTENSIONS_THEMES_URL. '/' . $theme . '/' . 'css/grid/720_grid.css',
$priority=1000,
$mimetype='test/css',
$media='screen and (min-width: 720px)',
$conditional='',
$attributes=array());

Services::Asset()->addCss($url = EXTENSIONS_THEMES_URL. '/' . $theme . '/' . 'css/grid/986_grid.css',
$priority=1000,
$mimetype='test/css',
$media='screen and (min-width: 986px)',
$conditional='',
$attributes=array());

Services::Asset()->addCss($url = EXTENSIONS_THEMES_URL. '/' . $theme . '/' . 'css/grid/1236_grid.css',
$priority=1000,
$mimetype='test/css',
$media='screen and (min-width: 1236px)',
$conditional='',
$attributes=array());

/** jQuery CDN and fallback */
Services::Asset()->addJs('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', 1);

/** Modernizer */
Services::Asset()->addJs('http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.5.3/modernizr.min.js', 10000);
/** HTML5 Shiv */
Services::Asset()->addJs('http://html5shiv.googlecode.com/svn/trunk/html5.js', 10000);

$url = EXTENSIONS_THEMES_URL . '/' . $theme . '/' . 'js/fallback/jquery-1.7.2.min.js';

$fallback = "
if (typeof jQuery == 'undefined') {
document.write(unescape(" . '"' . "%3Cscript src='" . $url . "' type='text/javascript'%3E%3C/script%3E" . '"' . "));
}";

Services::Asset()->addJSDeclarations($fallback, 'text/javascript', 10000);

/** Favicons */
Services::Asset()->addLink(
$url = EXTENSIONS_THEMES_URL . '/' . $theme . '/' . 'images/apple-touch-icon.png',
$relation = 'apple-touch-icon-precomposed',
$relation_type = 'rel',
$attributes = array()
);
Services::Asset()->addLink(
$url = EXTENSIONS_THEMES_URL . '/' . $theme . '/' . 'images/apple-touch-icon-72x72.png',
$relation = 'apple-touch-icon-precomposed',
$relation_type = 'rel',
$attributes = array('sizes,72x72')
);
Services::Asset()->addLink(
$url = EXTENSIONS_THEMES_URL . '/' . $theme . '/' . 'images/apple-touch-icon-114x114.png',
$relation = 'apple-touch-icon-precomposed',
$relation_type = 'rel',
$attributes = array('sizes,114x114')
);

return;
}

/**
* loadMediaPlus
*
@@ -18,6 +18,9 @@ STATUS_DRAFT="Draft"
STATUS_VERSION="Version"

; Dates
JUST_NOW="Just now"
AGO="ago"
YESTERDAY="Yesterday"
DATE_SECOND_SINGULAR="Second"
DATE_SECOND_PLURAL="Seconds"
DATE_MINUTE_SINGULAR="Minute"
@@ -117,29 +120,32 @@ FORM_SEARCH="Search"
FORM_SEARCH_DESC="Search description"
FORM_SEARCH_BUTTON="Search"
FORM_CLEAR_BUTTON="Clear"
SELECT_SEARCH="Search"
SELECT_AUTHOR="Author"
SELECT_CATEGORY="Category"
SELECT_CATALOG_TYPE_ID="Type"
SELECT_CREATED_BY="Author"
SELECT_TAG="Tag"
SELECT_GROUP="Group"
SELECT_FRIEND="Friend"
SELECT_STATUS="Status"
SELECT_FEATURED="Featured"
SELECT_SITE="Site"
SELECT_APPLICATION="Application"
SELECT_LANGUAGE="Language"
SELECT_COMPONENT="Component"
SELECT_MODULE="Module"
SELECT_THEME="Theme"
SELECT_VIEW_PAGE="Page"
SELECT_VIEW_TEMPLATE="Template"
SELECT_VIEW_WRAP="Wrap"
SELECT_SEARCH="Specify Search"
SELECT_AUTHOR="Select Author"
SELECT_CATEGORIES="Select Category"
SELECT_CATALOGTYPE="Select Catalog Type"
SELECT_CREATED_BY="Select Author"
SELECT_FEATURED="Select Featured"
SELECT_GROUPS="Select Groups"
SELECT_TAG="Select Tag"
SELECT_GROUP="Select Group"
SELECT_FRIEND="Select Friend"
SELECT_STATUS="Select Status"
SELECT_FEATURED="Selected Featured"
SELECT_SITE="Select Site"
SELECT_APPLICATION="Select Application"
SELECT_LANGUAGE="Select Language"
SELECT_COMPONENT="Select Component"
SELECT_MODULE="Select Module"
SELECT_TAGS="Select Tags"
SELECT_THEME="Select Theme"
SELECT_VIEW_PAGE="Select Page"
SELECT_VIEW_TEMPLATE="Select Template"
SELECT_VIEW_WRAP="Select Wrap"
SUBMENU_ITEMS="Items"
SUBMENU_CATEGORIES="Categories"
SUBMENU_DRAFTS="Drafts"
GRID_CHECK_ALL="Check all"
GRID_CHECK_ALL=""
GRID_ID_COLUMN_HEADING="ID"
GRID_EXTENSION_INSTANCE_ID_COLUMN_HEADING="Extension"
GRID_catalog_type_id_COLUMN_HEADING="Catalog Type"
@@ -199,3 +205,4 @@ FILTER_INVALID_VALUE="Invalid value provided for field: "
VALIDATE_FOREIGN_KEY="Validate Foreign Key: "
VALIDATE_HELPER_FUNCTION_NOT_FOUND="Validate Helper Function not found."
OPTIONS="Options"
ALL="All"
@@ -4,9 +4,7 @@
* @copyright 2012 Amy Stephen. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Molajo\Extension\Theme\Molajito\Helper;

use Molajo\Extension\Helper\MustacheHelper;
use Mustache\Mustache;
use Molajo\Service\Services;

/**
@@ -16,7 +14,7 @@
* @subpackage Helper
* @since 1.0
*/
Class ThemeMolajitoHelper extends MustacheHelper
Class ThemeMolajitoHelper extends Mustache
{
/**
* Parameters
@@ -134,4 +132,131 @@ public function loadMedia()

return;
}

/**
* items
*
* Returns a single row of information to mustache
* around the {# item } {/ item } controlbreak
*
* tracks row number in #this->rows so that resultset can be exploited
*
* @return ArrayIterator
* @since 1.0
*/
public function items()
{
$this->rows++;

return new \ArrayIterator($this->data);
}

/**
* gravatar
*
* Using the $this->row value, the data element introtext can be
* printed for this specific article.
*
* @return string
* @since 1.0
*/
public function gravatar()
{
$this->analytics();

return Services::Url()->getGravatar(
$email = 'AmyStephen@gmail.com',
$s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array()
);
}

/**
* analytics
*
* Google Analytics
*
* @return mixed
*/
public function analytics()
{
$code = Services::Registry()->get('Configuration', 'google_analytics_code', 'UA-1682054-15');
if (trim($code) == '') {
return;
}
$analytics = "
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '" . $code . "']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
";
Services::Asset()->addJSDeclarations($analytics, 'text/javascript', 1);
}

/**
* placeholder
*
* @return mixed
*/
public function placeholder()
{
return Services::Text()->getPlaceHolderText(106, array('html', 'lorem'));
}

/**
* intro
*
* Using the $this->row value, the data element introtext can be
* printed for this specific article.
*
* @return string
* @since 1.0
*/
public function intro()
{
if (isset($this->items['content_text'])) {
return Services::Text()->smilies($this->items['content_text']);
}
}

/**
* hello
*
* Returns hello for {{ hello }}
* Template example overrides for different result
*
* @return string
* @since 1.0
*/
public function hello()
{
return 'Hello!';
}

/**
* profile
*
* Renders the Author Profile Module for this article
*
* $results text
* $since 1.0
*/
public function profile()
{
return;
$class = 'Molajo\\Extension\\Includer\\ModuleIncluder';
$rc = new $class ('profile', '');

$attributes = array();
$attributes['name'] = 'dashboard';
$attributes['template'] = 'dashboard';
$attributes['wrap'] = 'section';
$attributes['id'] = $this->items['id'];

return $rc->process($attributes);
}
}
@@ -59,8 +59,8 @@ public function onAfterRoute()
}

/** Data Source Connection */
$model_type = $this->get('model_type');
$model_name = $this->get('model_name');
$model_type = $this->parameters['model_type'];
$model_name = $this->parameters['model_name'];

$controllerClass = 'Molajo\\MVC\\Controller\\ModelController';
$connect = new $controllerClass();
@@ -71,19 +71,19 @@ public function onAfterRoute()
}

$table_name = $connect->get('table_name');

$primary_prefix = $connect->get('primary_prefix');
$primary_key = $connect->get('primary_key');
$name_key = $connect->get('name_key');

$connect->set('use_special_joins', 1);

/** URL */
$url = Services::Registry()->get('Configuration', 'application_base_url');

if (Services::Registry()->get('Configuration', 'url_sef') == 1) {
$url .= '/' . $this->get('catalog_url_sef_request');
$url .= '/' . $this->parameters['catalog_url_sef_request'];
$connector = '?';
} else {
$url .= '/' . $this->get('catalog_url_request');
$url .= '/' . $this->parameters['catalog_url_request'];
$connector = '&';
}

@@ -102,6 +102,9 @@ public function onAfterRoute()
/** Create Pagination data and store in Trigger registry */
$this->setPagination($url, $connector);

/** Create data for batch work area */
$this->setBatch($connect, $primary_prefix);

return true;
}

@@ -163,9 +166,25 @@ protected function setToolbar($url, $connector)
*/
protected function setFilter($connect, $primary_prefix)
{
$grid_list = explode(',', $this->get(
'grid_list', 'catalog_type_id,created_by,featured,status')
);
$grid_list = explode(',', $this->get('grid_list', 'CatalogType,Author,Featured,Status'));

/** Add lists needed for Batch Updates */
if (in_array('Status', $grid_list)) {
} else {
$grid_list[] = 'Status';
}
if (in_array('Categories', $grid_list)) {
} else {
$grid_list[] = 'Categories';
}
if (in_array('Tags', $grid_list)) {
} else {
$grid_list[] = 'Tags';
}
if (in_array('Groups', $grid_list)) {
} else {
$grid_list[] = 'Groups';
}

$lists = array();

@@ -217,56 +236,6 @@ protected function setFilter($connect, $primary_prefix)
return true;
}

/**
* Create Batch lists and store in Trigger registry, given ACL checks
*
* @return boolean
* @since 1.0
*/
protected function setBatch($connect, $primary_prefix)
{
$grid_list = Services::Registry()->set('Trigger', 'GridFilters');

$batch_list = explode(',', 'status,categories,tags,access');

$lists = array();

if (is_array($batch_list) && count($batch_list) > 0) {

/** Build each list and store in registry along with current selection */
foreach ($batch_list as $list) {

$fieldValue = Services::Text()->getList($list, $this->parameters);

if ($fieldValue == false) {
} else {

ksort($fieldValue);

Services::Registry()->set('Trigger', 'batch_' . $list, $fieldValue);

/** todo: Retrieve selected field from request */
$selectedValue = '';
Services::Registry()->set('Trigger', 'batch_' . $list . '_selected', $selectedValue);

if ($selectedValue == '') {
} else {
$connect->model->query->where($connect->model->db->qn($primary_prefix)
. '.' . $connect->model->db->qn($list)
. ' = ' . $connect->model->db->q($selectedValue));
}

/** Store the name of each filter list in an array */
$lists[] = strtolower($list);
}
}
}

Services::Registry()->set('Trigger', 'GridBatch', $lists);

return true;
}

/**
* Create Grid Query and save results in Trigger registry
*
@@ -279,39 +248,24 @@ protected function setBatch($connect, $primary_prefix)
*/
protected function setGrid($connect, $primary_prefix, $table_name)
{

/** Select */
/** Present these columns in the list */
$grid_columns = explode(',', $this->get('grid_columns',
'id,featured,title,created_by,start_publishing_datetime,ordering')
'title,created_by,start_publishing_datetime,ordering')
);
Services::Registry()->set('Trigger', 'GridTableColumns', $grid_columns);
foreach ($grid_columns as $column) {
$connect->model->query->select(
$connect->model->db->qn($primary_prefix) . '.' . $connect->model->db->qn($column)
);
}

/** From */
$connect->model->query->from($connect->model->db->qn($table_name)
. ' as ' . $connect->model->db->qn($primary_prefix));

/** Where (filter values already set) */
$connect->model->query->where($connect->model->db->qn('a.catalog_type_id')
. ' = ' . $this->get('menuitem_source_catalog_type_id'));
$connect->model->query->where($connect->model->db->qn('catalog.redirect_to_id') . ' = ' . 0);

/** Ordering */
$ordering = $this->get('grid_ordering', 'start_publishing_datetime');
Services::Registry()->set('Trigger', 'GridTableOrdering', $ordering);
$connect->model->query->order($connect->model->db->qn($ordering));

/** Run the query and store results */
$connect->model->db->setQuery(
$connect->model->query->__toString(),
$this->get('grid_offset', 0),
$this->get('grid_count', 5)
);

$query_results = $connect->model->db->loadObjectList();
$query_results = $connect->getData('list');

Services::Registry()->set('Trigger', 'GridQueryResults', $query_results);

@@ -362,4 +316,54 @@ protected function setPagination($url, $connector)

return true;
}

/**
* Create Batch lists and store in Trigger registry, given ACL checks
*
* @return boolean
* @since 1.0
*/
protected function setBatch($connect, $primary_prefix)
{
$grid_list = Services::Registry()->set('Trigger', 'GridFiltersxx');

$batch_list = explode(',', 'status,categories,tags,access');

$lists = array();

if (is_array($batch_list) && count($batch_list) > 0) {

/** Build each list and store in registry along with current selection */
foreach ($batch_list as $list) {

$fieldValue = Services::Text()->getList($list, $this->parameters);

if ($fieldValue == false) {
} else {

ksort($fieldValue);

Services::Registry()->set('Trigger', 'batch_' . $list, $fieldValue);

/** todo: Retrieve selected field from request */
$selectedValue = '';
Services::Registry()->set('Trigger', 'batch_' . $list . '_selected', $selectedValue);

if ($selectedValue == '') {
} else {
$connect->model->query->where($connect->model->db->qn($primary_prefix)
. '.' . $connect->model->db->qn($list)
. ' = ' . $connect->model->db->q($selectedValue));
}

/** Store the name of each filter list in an array */
$lists[] = strtolower($list);
}
}
}

Services::Registry()->set('Trigger', 'GridBatchxx', $lists);

return true;
}
}
@@ -100,6 +100,12 @@ public function onAfterRoute()
protected function setMenu()
{
$extension_instance_id = Services::Registry()->get('Parameters', 'menu_extension_instance_id');
if ((int) $extension_instance_id == 0) {
$catalog_type_id = Services::Registry()->get('Parameters', 'catalog_type_id');
if ((int) $catalog_type_id == 10000) {
$extension_instance_id = 100;
}
}

$bread_crumbs = Services::Menu()->getMenuBreadcrumbIds($extension_instance_id);

@@ -36,6 +36,14 @@ class ContentTrigger extends Trigger
*/
protected $table_registry_name;

/**
* Model name
*
* @var object
* @since 1.0
*/
protected $model_name;

/**
* Parameters set by the Includer and used in the MVC to generate include output
*
@@ -100,6 +108,14 @@ class ContentTrigger extends Trigger
*/
protected $customfieldgroups;

/**
* Used in post-render View triggers, contains output rendered from view
*
* @var object
* @since 1.0
*/
protected $rendered_output;

/**
* getInstance
*
@@ -130,9 +146,9 @@ public function get($key, $default = null)
{
$value = null;

if (in_array($key, array('table_registry_name', 'query', 'db',
'query_results', 'null_date', 'now', 'parameters', 'fields',
'customfieldgroups'))) {
if (in_array($key, array('table_registry_name', 'query', 'db', 'parameters',
'query_results', 'null_date', 'now', 'fields', 'customfieldgroups',
'model_name', 'rendered_output'))) {
$value = $this->$key;

} else {
@@ -160,7 +176,8 @@ public function get($key, $default = null)
public function set($key, $value = null)
{
if (in_array($key, array('table_registry_name', 'query', 'db', 'parameters',
'query_results', 'null_date', 'now', 'fields', 'customfieldgroups'))) {
'query_results', 'null_date', 'now', 'fields', 'customfieldgroups',
'model_name', 'rendered_output'))) {

$this->$key = $value;
} else {
@@ -186,11 +203,12 @@ public function setFields()
/** process normal fields */
$fields = Services::Registry()->get($this->table_registry_name, 'fields');

/** Common processing */
/** "Normal" fields */
if (is_array($fields) && count($fields) > 0) {
$this->processFieldType($type = '', $fields);
}

/** "Custom" fields */
$this->customfieldgroups = Services::Registry()->get($this->table_registry_name, 'customfieldgroups', array());

if (is_array($this->customfieldgroups) && count($this->customfieldgroups) > 0) {
@@ -208,6 +226,14 @@ public function setFields()
}
}

/** join fields */
$joinfields = Services::Registry()->get($this->table_registry_name, 'JoinFields');

/** "Normal" fields */
if (is_array($joinfields) && count($joinfields) > 0) {
$this->processFieldType('JoinFields', $joinfields);
}

return $this;
}

@@ -230,7 +256,21 @@ public function processFieldType($type, $fields)
$row->name = 'Unknown';
}

/** Datatype */
/** As Name */
if (isset($fields[$key]['as_name'])) {
$row->name = $fields[$key]['as_name'];
} else {
$row->name = '';
}

/** Alias */
if (isset($fields[$key]['alias'])) {
$row->type = $fields[$key]['alias'];
} else {
$row->type = '';
}

/** Datatype */
if (isset($fields[$key]['type'])) {
$row->type = $fields[$key]['type'];
} else {
@@ -307,7 +347,14 @@ public function processFieldType($type, $fields)
$row->size = '0';
}

/** Unique */
/** Table */
if (isset($fields[$key]['table'])) {
$row->size = $fields[$key]['table'];
} else {
$row->table = '';
}

/** Unique */
if (isset($fields[$key]['unique'])) {
$row->unique = $fields[$key]['unique'];
} else {
@@ -331,7 +378,7 @@ public function processFieldType($type, $fields)
}

/**
* processFieldType processes an array of fields, populating the class property
* retrieveFieldsByType processes an array of fields, populating the class property
*
* @return boolean
* @since 1.0
@@ -82,7 +82,7 @@ public function onBeforeViewRender()
if (trim($class) == '') {
$class = '';
} else {
$class = htmlspecialchars(trim($class), ENT_NOQUOTES, 'UTF-8') . ' class="' . '"';
$class = ' class="' . htmlspecialchars(trim($class), ENT_NOQUOTES, 'UTF-8') . '"';
}

/** @var $css_id */
@@ -58,8 +58,6 @@ public function onAfterRead()

if (is_array($fields) && count($fields) > 0) {

/** @noinspection PhpWrongForeachArgumentTypeInspection */
/** @noinspection PhpWrongForeachArgumentTypeInspection */
foreach ($fields as $field) {

$name = $field->name;
@@ -69,6 +67,7 @@ public function onAfterRead()

if ($fieldValue == false
|| $fieldValue == '0000-00-00 00:00:00') {

} else {

/** formats the date for CCYYMMDD */
@@ -79,19 +78,19 @@ public function onAfterRead()

/** Creates the new 'normal' or special field and populates the value */
$new_name = $name . '_ccyymmdd';
$newFieldValue = str_replace('-', '', $newFieldValue);
$fieldValue = $this->saveField($field, $new_name, $newFieldValue);
$this->saveField($field, $new_name, $newFieldValue);
$fieldValue = $newFieldValue;
}

/** NN days ago */
$newFieldValue = Services::Date()->differenceDays(date('Y-m-d'), $fieldValue);
/** Using newly formatted date, calculate NN days ago */
$newFieldValue = Services::Date()->differenceDays($fieldValue);

if ($newFieldValue == false) {
} else {

/** Creates the new 'normal' or special field and populates the value */
$new_name = $name . '_n_days_ago';
$fieldValue = $this->saveField($field, $new_name, $newFieldValue);
$this->saveField($field, $new_name, $newFieldValue);
}

/** Pretty Date */
@@ -102,7 +101,7 @@ public function onAfterRead()

/** Creates the new 'normal' or special field and populates the value */
$new_name = $name . '_pretty_date';
$fieldValue = $this->saveField($field, $new_name, $newFieldValue);
$this->saveField($field, $new_name, $newFieldValue);
}
}
}
@@ -6,6 +6,7 @@
*/
namespace Molajo\Extension\Trigger\Itemurl;

use Molajo\Service\Services;
use Molajo\Extension\Trigger\Content\ContentTrigger;

defined('MOLAJO') or die;
@@ -76,7 +77,7 @@ public function onAfterRead()
} else {

/** Creates the new 'normal' or special field and populates the value */
$newFieldName = $name . '_' . 'Url';
$newFieldName = $name . '_' . 'url';
$fieldValue = $this->saveField($field, $newFieldName, $newField);
}
}
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="1.0" type="trigger">
<name>MUSTACHE_TRIGGER_NAME</name>
<author>Amy Stephen</author>
<create_date>May 2012</create_date>
<copyright>Copyright (C) 2012 Amy Stephen. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later http://www.gnu.org/licenses/gpl.html</license>
<author_email>AmyStephen@gmail.com</author_email>
<author_url>http://molajo.org</author_url>
<version>1.0</version>
<description>MUSTACHE_TRIGGER_DESCRIPTION</description>
</extension>

@@ -0,0 +1,7 @@
; Molajo Project
; Copyright (C) 2012 Amy Stephen. All rights reserved.
; License GNU General Public License version 2 or later http://www.gnu.org/licenses/gpl.html
; Note : All ini files need to be saved as UTF-8

MUSTACHE_TRIGGER_NAME="Mustache Trigger"
MUSTACHE_TRIGGER_DESCRIPTION="Mustache Trigger"
@@ -0,0 +1,156 @@
<?php
/**
* @package Molajo
* @copyright 2012 Amy Stephen. All rights reserved.
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/
namespace Molajo\Extension\Trigger\Mustache;

use Molajo\Extension\Trigger\Content\ContentTrigger;
use Mustache\Mustache;
use Molajo\Service\Services;

defined('MOLAJO') or die;

/**
* @package Molajo
* @subpackage Trigger
* @since 1.0
*/
class MustacheTrigger extends ContentTrigger
{
/**
* Static instance
*
* @var object
* @since 1.0
*/
protected static $instance;

/**
* Parameters passed in by Controller when class instantiated
*
* @var object
* @since 1.0
*/
public $parameters;

/**
* $data
*
* Allows collection of any set of data for a single $item
*
* @var array
* @since 1.0
*/
public $data = array();

/**
* $rows
*
* Retains pointer to current row contained within the $data array
*
* @var int
* @since 1.0
*/
protected $rows = 0;

/**
* getInstance
*
* @static
* @return bool|object
* @since 1.0
*/
public static function getInstance()
{
if (empty(self::$instance)) {
self::$instance = new MustacheTrigger();
}

return self::$instance;
}

/**
* Rendered results from Views can be further processed
*
* @return void
* @since 1.0
*/
public function onAfterViewRender()
{
if ($this->rendered_output == '' || $this->rendered_output === null) {
return;
}

if ($this->get('mustache', 0) == 1) {
} else {
return;
}

/** Quick check for Mustache Syntax */
if (stripos($this->rendered_output, '}}') > 0) {
} else {
return;
}

/** Passes the rendered output and query_results into the Mustache Theme Helper for processing. */

/** Instantiate Mustache before Theme Helper */
$m = new Mustache;

/** Theme Specific Mustache Helper or Molajo Mustache Helper */
$helperClass = 'Molajo\\Extension\\Theme\\'
. ucfirst(Services::Registry()->get('Parameters', 'theme_path_node')) . '\\Helper\\'
. 'Theme' . ucfirst(Services::Registry()->get('Parameters', 'theme_path_node')) . 'Helper';

if (\class_exists($helperClass)) {
} else {
return;
}
/** Instantiate Class */
$h = new $helperClass();

/** Push in Parameters */
$h->parameters = $this->parameters;

/** Push in Query Results */
$h->items = $this->query_results;

/** Push in model results */
$totalRows = count($this->query_results);

if (($this->query_results) == false) {
$totalRows = 0;
}

if (is_object($this->query_results)) {

if ($totalRows > 0) {
foreach ($this->query_results as $this->row) {

$item = new \stdClass ();
$pairs = get_object_vars($this->row);
foreach ($pairs as $key => $value) {
$item->$key = $value;
}

$new_query_results[] = $item;
}
}

/** Load -- Associative Array */
} else {
$new_query_results = $this->query_results;
}

/** Pass in Rendered Output and Helper Class Instance */
ob_start();
echo $h->render($this->rendered_output);
$this->rendered_output = ob_get_contents();
ob_end_clean();

/** Complete */
return;
}
}
@@ -45,7 +45,7 @@ public static function getInstance()
/**
* Before the Query results are injected into the View
*
* @return boolean
* @return boolean
* @since 1.0
*/
public function onBeforeViewRender()
@@ -63,15 +63,15 @@ public function onBeforeViewRender()
foreach ($this->query_results as $item) {

if ($i == 1) {
$item->first_row = 1;
$item->first_row = 'first';
} else {
$item->first_row = 0;
$item->first_row = '';
}

if ($i == $count) {
$item->last_row = 1;
$item->last_row = 'last';
} else {
$item->last_row = 0;
$item->last_row = '';
}

$item->total_records = $count;
@@ -83,6 +83,10 @@ public function onBeforeViewRender()
$even_or_odd = 'odd';
}

$item->grid_row_class = ' class="' .
trim(trim($item->first_row) . ' ' . trim($item->even_or_odd_row) . ' ' . trim($item->last_row))
. '"';

$item->row_number = $i++;
}

@@ -1,10 +1,7 @@
<?php
use Molajo\Service\Services;
/**
*
*
*
* <include:template name=Admingridbatch/>
* <include:template name=Admintoolbar/>
* @package Molajito
* @copyright 2012 Amy Stephen. All rights reserved.
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
@@ -14,20 +11,19 @@
<include:template name="Adminheader" wrap="header" wrap_class="row"/>
<include:message wrap="div" wrap_class="row"/>
<section class="row">
<nav class="four columns">
<nav class="three columns">
<include:template name=Adminnavigationbar/>
<include:template name=Adminsubmenu/>
<include:template name=Admingridfilters/>
<include:template name=Adminsectionmenu/>
</nav>
<section class="eight columns">
<include:template name=Admintoolbar/>
<include:template name=Admingridfilters/>
<include:template name=Search/>
<section class="nine columns">
<include:template name=Adminsubmenu/>
<include:request/>
<include:template name=Admingridbatch/>
</section>
</section>
<footer class="row">
<div class="four columns"></div>
<div class="eight columns"><include:template name=Adminfooter wrap=none/></div>
<div class="three columns"></div>
<div class="nine columns"><include:template name=Adminfooter wrap=none/></div>
</footer>
<include:defer/>
@@ -6,4 +6,4 @@
*/
use Molajo\Service\Services;
defined('MOLAJO') or die; ?>
<li<?php echo $this->row->css_class; ?>><a href="<?php echo $this->row->link; ?>"><?php echo $this->row->link_text; ?></a></li>
<dd<?php echo $this->row->css_class; ?>><a href="<?php echo $this->row->link; ?>"><?php echo $this->row->link_text; ?></a></dd>
@@ -5,4 +5,4 @@
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/
defined('MOLAJO') or die; ?>
</ul>
</dl>
@@ -5,7 +5,16 @@
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/
use Molajo\Service\Services;
$bread_crumbs = Services::Registry()->get('Trigger', 'AdminBreadcrumbs');
if (count($bread_crumbs) > 0) {
foreach ($bread_crumbs as $crumb) {
if ($crumb->component == 1) {
$component = $crumb->url;
break;
}
}
}
defined('MOLAJO') or die; ?>
<h3><?php echo Services::Language()->translate('OPTIONS'); ?></h3>
<ul class="submenu">

<dl class="sub-nav">
<dt><?php echo Services::Language()->translate('OPTIONS'); ?></dt>
<dd class="active"><a href="<?php echo $component; ?>"><?php echo Services::Language()->translate('ALL'); ?></a></dd>
@@ -7,7 +7,6 @@
*/
defined('MOLAJO') or die;

$date = Services::Date()->getDate()->format('Y-m-d-H-i-s');
$current_year = Services::Date()->getDate()->format('Y');
$first_year = $this->row->copyright_first_year;

@@ -6,34 +6,24 @@
*/
use Molajo\Service\Services;
defined('MOLAJO') or die;
$rowCount = Services::Registry()->get('Trigger', 'GridTableRows') % 2;
if ($rowCount == 0) {
$rowClass = ' class="even"';
} else {
$rowClass = ' class="odd"';
}
?>
<tr<?php echo $rowClass ?>>
<?php
$columnCount = 1;
$columnArray = Services::Registry()->get('Trigger', 'GridTableColumns');
foreach ($columnArray as $column) {
$extraClass = '';
if ($columnCount == 1) {
$extraClass .= 'first';
}
if ($extraClass == '') {
} else {
$extraClass = ' class="' . trim($extraClass) . '"';
}
?>
<td<?php echo $extraClass; ?>>
<?php echo $this->row->$column; ?>
</td>
<?php
$columnCount++;
} ?>
<td class="center last">
<input type=checkbox value="<?php echo $checked; ?>">
</td>
</tr>
<tr<?php echo $this->row->grid_row_class; ?>><?php
$columnCount = 1;
$columnArray = Services::Registry()->get('Trigger', 'GridTableColumns');
foreach ($columnArray as $column) { ?>
<td<?php echo $this->row->css_class; ?>><?php
if ($column == 'title') {
echo '<a href="' . $this->row->catalog_id_url . '">';
}
echo $this->row->$column;
if ($column == 'title') {
echo '</a>';
} ?>
</td><?php
$columnCount++;
}
?>
<td class="center last">
<input type=checkbox value="<?php echo $checked; ?>">
</td>
</tr>
@@ -6,12 +6,13 @@
*/
use Molajo\Service\Services;
defined('MOLAJO') or die;
$columns = Services::Registry()->get('Trigger', 'GridTableColumns');
$columnCount = count($columns) + 1; ?>

$columnCount = Services::Registry()->get('Trigger', 'GridTableColumns');
?>
</tbody>
<tfoot>
<tr>
<td colspan="<?php echo $columnCount; ?>">
<td colspan="<?php echo ((int) $columnCount + 1); ?>">
<include:template name=Admingridpagination wrap=None value=GridPagination/>
</td>
</tr>
@@ -6,32 +6,48 @@
*/
use Molajo\Service\Services;
defined('MOLAJO') or die;
?>
<dl class="nice vertical tabs">
<dd><a href="<?php echo $pageUrl; ?>#batch1" class="active">Status</a></dd>
<dd><a href="<?php echo $pageUrl; ?>#batch2">Categories</a></dd>
<dd><a href="<?php echo $pageUrl; ?>#batch3">Tags</a></dd>
<dd><a href="<?php echo $pageUrl; ?>#batch4">Access</a></dd>
</dl>

<ul class="nice tabs-content vertical">
<li class="active" id="batch1Tab">
<fieldset class="batch">
<legend><?php echo Services::Language()->translate('GRID_BATCH_OPTIONS');?></legend>
<p><?php echo Services::Language()->translate('Change the status of selected items to this value.');?></p>

<button type="submit">
<?php echo Services::Language()->translate('GRID_SUBMIT'); ?>
</button>
$action = Services::Registry()->get('Trigger', 'PageURL');
?>
<form action="<?php echo $action; ?>" method="post" name="Admingridfilters">
<section class="row">
<section class="three columns">
<dl class="nice vertical tabs">
<dd><a href="<?php echo $pageUrl; ?>#batchStatus" class="active">Status</a></dd>
<dd><a href="<?php echo $pageUrl; ?>#batchCategories">Categories</a></dd>
<dd><a href="<?php echo $pageUrl; ?>#batchTags">Tags</a></dd>
<dd><a href="<?php echo $pageUrl; ?>#batchPermissions">Permissions</a></dd>
</dl>
</section>
<section class="nine columns">
<ul class="nice tabs-content vertical">
<li class="active" id="batchStatusTab">
<div class="panel">
<h4>Status</h4>

<button type="button">
<?php echo Services::Language()->translate('GRID_CLEAR'); ?>
</button>
<p>Change the items selected, above to the specified status.</p>
</div>
</li>
<li id="batchCategoriesTab">
<div class="panel">
<h4>Categories</h4>

</fieldset>
</li>
<li id="batch2Tab">This is nice tab 2's content. Now you see it!</li>
<li id="batch3Tab">This is nice tab 3's content. It's, you know...okay.</li>
</ul>
<p>Seriously, just look at this sweet panel.</p>
</div>
</li>
<li id="batchTagsTab">
<div class="panel">
<h4>Tags</h4>

<p>Seriously, just look at this sweet panel.</p>
</div>
</li>
<li id="batchPermissionsTab">
<div class="panel">
<h4>P</h4>
</div>
</li>
</ul>
</section>
</section>
</form>
@@ -5,6 +5,5 @@
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/
defined('MOLAJO') or die; ?>
<input type="submit" class="submit button small nice" name="submit" id="searchsubmit" value="Filter">
</form>

@@ -10,3 +10,4 @@
$action = Services::Registry()->get('Trigger', 'PageURL');
?>
<form action="<?php echo $action; ?>" method="post" name="Admingridfilters">
<include:template name=Search/>
@@ -4,9 +4,9 @@
@copyright Copyright (C) 2012 Amy Stephen. All rights reserved.
@license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/
ul.nav-section { list-style: none; margin-left: 10px; overflow: hidden; margin-top: 0;}
ul.nav-section li { float: left; margin-bottom: 10px; margin-right: 15px; color: #999;}
ul.nav-section { list-style: none; margin-left: 5px; overflow: hidden; margin-top: 0;}
ul.nav-section li { float: left; margin-bottom: 10px; margin-right: 5px; color: #999;}
ul.nav-section li a { display: block; padding: 0 7px 4px; color: #555; }
ul.nav-section li.current a, ul.nav-section li:hover a, ul.nav-section li a:focus { border-bottom: solid 2px #00a6fc; color: #141414; }
ul.nav-section li.last-in-row { margin-right: 0; }
ul.nav-section li span { font-size: 20px }
ul.nav-section li span { font-size: 14px }
@@ -6,8 +6,8 @@
*/
use Molajo\Service\Services;
defined('MOLAJO') or die;
//todo - add first and last indicators in the row
if ($this->row->title == 'Install') {

if ($this->row->last_row == 1) {
$liclass = ' class="last-in-row"';
} else {
$liclass = '';
@@ -7,7 +7,5 @@
use Molajo\Service\Services;
defined('MOLAJO') or die;
$action = Services::Registry()->get('Trigger', 'PageURL'); ?>
<form action="<?php echo $action; ?>" method="post" name="Adminsearch">
<input type="submit" class="submit button small" name="submit" id="searchsubmit" value="Filter">
<input type="search" placeholder="Search..." name="s" >
<input type="submit" value="Search" />
</form>
@@ -23,7 +23,6 @@

use Molajo\Application;
use Molajo\Service\Services;
use Mustache\Mustache;

defined('MOLAJO') or die;

@@ -82,16 +81,14 @@ public function display()

$table_registry_name = ucfirst(strtolower($model_type)) . ucfirst(strtolower($model_name));

$this->getTriggerList($model_query_object);

if ($model_name == '') {
$this->query_results = array();

} else {
$this->connect($model_type, $model_name);

if ((int)$this->get('content_id') == 0) {

//todo dbo should be result, item, list too - add parameter for specific query, don't hijack.
} elseif (strtolower($model_type) == 'dbo') {

} else {
@@ -103,6 +100,7 @@ public function display()
$this->getData($model_query_object);
}

//todo - move this into a trigger?
$this->pagination = array();

/** no results */
@@ -113,7 +111,7 @@ public function display()
}

if (strtolower($includer_name) == 'wrap') {
$renderedOutput = $this->query_results;
$rendered_output = $this->query_results;

} else {

@@ -140,35 +138,36 @@ public function display()
}

/** Render View */
$renderedOutput = $this->renderView();
$rendered_output = $this->renderView();

/** Trigger After-View Render Event */
$this->onAfterViewRender($renderedOutput);
$rendered_output = $this->onAfterViewRender($rendered_output);
}

/** Wrap template view results */
return $this->wrapView($this->get('wrap_view_title'), $renderedOutput);
return $this->wrapView($this->get('wrap_view_title'), $rendered_output);
}

/**
* wrapView
*
* @param $view
* @param $renderedOutput
* @param $rendered_output
*
* @return string
* @since 1.0
*/
public function wrapView($view, $renderedOutput)
public function wrapView($view, $rendered_output)
{
//todo: decide if not passing wraps thru view triggers will come back and bite us in the ass.
$this->query_results = array();

$temp = new \stdClass();

$this->set('view_css_id', $this->get('wrap_view_css_id'));
$this->set('view_css_class', $this->get('wrap_view_css_class'));

$temp->content = $renderedOutput;
$temp->content = $rendered_output;

$this->query_results[] = $temp;

@@ -222,8 +221,8 @@ protected function onBeforeViewRender()
*
* On no query results
*
* @return string
* @since 1.0
* @return string
* @since 1.0
*/
protected function renderView()
{
@@ -282,22 +281,17 @@ protected function renderView()
* @return bool
* @since 1.0
*/
protected function onAfterViewRender($renderedOutput)
protected function onAfterViewRender($rendered_output)
{
if ((int)$this->get('process_triggers') == 0) {
return true;
return $rendered_output;
}

/** Mustache */
// if ($this->get('mustache', 0) == 1) {
// $renderedOutput = $this->processRenderedOutput($renderedOutput);
// }

/** Process the entire query_results set */
$arguments = array(
'table_registry_name' => $this->table_registry_name,
'parameters' => $this->parameters,
'rendered_output' => $renderedOutput,
'rendered_output' => $rendered_output,
'model_name' => $this->get('model_name')
);

@@ -307,86 +301,8 @@ protected function onAfterViewRender($renderedOutput)
return false;
}

$renderedOutput = $arguments['renderedOutput'];

return $renderedOutput;
}
$rendered_output = $arguments['rendered_output'];

/**
* todo: create a trigger action here to invoke template tools, like mustache.
*
* processRenderedOutput
*
* Passes the rendered output and the entire resultset into the
* Theme Helper and Mustache for processing.
*
* @param $template
*
* @return string rendered output
* @since 1.0
*/
protected function processRenderedOutput($template)
{
/** quick check for mustache commands */
if (stripos($template, '}}') > 0) {
} else {
return $template;
}

/** Instantiate Mustache before Theme Helper */
$m = new Mustache;

/** Theme Specific Mustache Helper or Molajo Mustache Helper */
$helperClass = 'Molajo\\Extension\\Theme\\'
. ucfirst(Services::Registry()->get('Parameters', 'theme_path_node')) . '\\Helper\\'
. 'Theme' . ucfirst(Services::Registry()->get('Parameters', 'theme_path_node')) . 'Helper';

if (\class_exists($helperClass)) {
$h = new $helperClass();

} else {
$helperClass = 'Molajo\\Extension\\Helper\\MustacheHelper';
$h = new $helperClass();
}

/** Push in Parameters */
$h->parameters = $this->parameters;
$h->items = $this->query_results;
/** Push in model results */
$totalRows = count($this->query_results);

if (($this->query_results) == false) {
$totalRows = 0;
}

if (is_object($this->query_results)) {

if ($totalRows > 0) {
foreach ($this->query_results as $this->row) {

$item = new \stdClass ();
$pairs = get_object_vars($this->row);
foreach ($pairs as $key => $value) {
$item->$key = $value;
}

$new_query_results[] = $item;
}
}

/** Load -- Associative Array */
} else {
$new_query_results = $this->query_results;
}

/** Pass in Rendered Output and Helper Class Instance */
ob_start();
echo $h->render($template);
$output = ob_get_contents();
ob_end_clean();

/** Return processed output */

return $output;
return $rendered_output;
}
}
@@ -286,11 +286,20 @@ public function getData($query_object = 'list')
}

/** Executes Query */
if ($query_object == 'distinct') {
$offset = 0;
$count = 999999;

} else {
$offset = $this->get('model_offset', 0);
$count = $this->get('model_count', 5);
}

$this->model->getQueryResults(
Services::Registry()->get($this->table_registry_name, 'Fields'),
$query_object,
$this->get('model_offset', 0),
$this->get('model_count', 5)
$offset,
$count
);

/** Retrieve query results from Model */
@@ -111,6 +111,7 @@ public function get($key, $default = null)

if (in_array($key, array('db', 'query', 'null_date', 'now', 'query_results', 'pagination'))) {
$value = $this->$key;

} else {
if (isset($this->parameters[$key])) {
$value = $this->parameters[$key];
@@ -161,11 +161,6 @@ public function useSpecialJoins($joins, $primary_prefix, $query_object)
$joinTo = $join['jointo'];
$joinWith = $join['joinwith'];

/* Join to table */
if (trim($alias) == '') {
$alias = substr($join_table, 3, strlen($join_table));
}

$this->query->from($this->db->qn($join_table) . ' as ' . $this->db->qn($alias));

/* Select fields */
@@ -61,9 +61,9 @@ public static function getInstance($configuration_file = null)
public function __construct($configuration_file = null)
{
/** Initialize list of valid field attributes */
self::$valid_field_attributes = array('name', 'type', 'default', 'file',
self::$valid_field_attributes = array('name', 'asname', 'alias', 'type', 'default', 'file',
'identity', 'length', 'minimum', 'maximum', 'null', 'required',
'shape', 'size', 'unique', 'values');
'shape', 'size', 'table', 'unique', 'values');

/** Retrieve Site Data */
$this->getSite($configuration_file);
@@ -815,24 +815,69 @@ public static function setTableJoinsRegistry(
if (isset($xml->table->joins->join)) {
$jXML = $xml->table->joins->join;

$join_fields_select = array();

$jArray = array();
foreach ($jXML as $joinItem) {

$joinVars = get_object_vars($joinItem);
$joinAttributes = ($joinVars["@attributes"]);
$joinAttributesArray = array();

$joinAttributesArray['table'] = (string)$joinAttributes['table'];
$joinAttributesArray['alias'] = (string)$joinAttributes['alias'];
$joinAttributesArray['select'] = (string)$joinAttributes['select'];
$joinModel = (string)$joinAttributes['model'];

$joinFields = array();

/** Load Registry for Table Joined too -- so that field attributes can be used */
$joinRegistry = strtolower($joinModel . 'Table');

/** Load the file and build registry - IF - the registry is not already loaded */
if (Services::Registry()->exists($joinRegistry) == true) {
} else {
//if not, load it.
$controllerClass = 'Molajo\\MVC\\Controller\\ModelController';
$m = new $controllerClass();
$results = $m->connect('Table', $joinModel);
}

/** Load inherited definitions */
$tempFields = Services::Registry()->get($joinRegistry, 'fields', array());
$table = Services::Registry()->get($joinRegistry, 'table');
$joinAttributesArray['table'] = $table;

$alias = (string)$joinAttributes['alias'];
if (trim($alias) == '') {
$alias = substr($table, 3, strlen($table));
}
$joinAttributesArray['alias'] = trim($alias);

$select = (string)$joinAttributes['select'];
$joinAttributesArray['select'] = $select;
$selectArray = explode(',', $select);

foreach ($selectArray as $x) {

foreach($tempFields as $t) {
if ($t['name'] == $x) {
$t['as_name'] = trim($alias) . '_' . trim($x);
$t['alias'] = $alias;
$t['table'] = $table;
$join_fields_select[] = $t;
}
}
}

$joinAttributesArray['jointo'] = (string)$joinAttributes['jointo'];
$joinAttributesArray['joinwith'] = (string)$joinAttributes['joinwith'];

$jArray[] = $joinAttributesArray;
}

Services::Registry()->set($registryName, 'Joins', $jArray);

Services::Registry()->set($registryName, 'JoinFields', $join_fields_select);
}

return array($xml, $xml_string);
}

Large diffs are not rendered by default.

@@ -181,6 +181,12 @@ public function getMenuBreadcrumbIds($extension_instance_id)
}

$current_menuitem_id = Services::Registry()->get('Parameters', 'catalog_source_id');
if ((int) $current_menuitem_id == 0) {
$current_menuitem_id = Services::Registry()->get('Parameters', 'parent_menuitem');
}
if ((int) $current_menuitem_id == 0) {
return false;
}

/** Query Connection */
$controllerClass = 'Molajo\\MVC\\Controller\\ModelController';
@@ -208,6 +214,29 @@ public function getMenuBreadcrumbIds($extension_instance_id)
$item->url = Services::Url()->getApplicationURL('index.php?id=' . (int)$item->id);
}
}
if ($item->lvl == 1) {
$item->home = 1;
$item->section = 0;
$item->component = 0;
$item->submenu = 0;

} elseif ($item->lvl == 2) {
$item->home = 0;
$item->section = 1;
$item->component = 0;
$item->submenu = 0;

} elseif ($item->lvl == 3) {
$item->home = 0;
$item->section = 0;
$item->component = 1;
$item->submenu = 0;
} else {
$item->home = 0;
$item->section = 0;
$item->component = 0;
$item->submenu = 4;
}
}

return $query_results;
@@ -268,22 +268,91 @@ public function getList($filter, $parameters)
$primary_key = $m->get('primary_key');
$name_key = $m->get('name_key');

$filter_check_published_status = $m->get('filter_check_published_status');
$m->model->set('model_offset', 0);
$m->model->set('model_count', 999999);

/** Select */
$fields = Services::Registry()->get($filter.'Listbox', 'Fields');

$first = true;

if (count($fields) < 2) {

$m->model->query->select('DISTINCT '. $m->model->db->qn($primary_prefix . '.' . $primary_key) . ' as id');
$m->model->query->select($m->model->db->qn($primary_prefix . '.' . $name_key) . ' as value');
$m->model->query->order($m->model->db->qn($primary_prefix . '.' . $name_key) . ' ASC');

} else {
foreach ($fields as $field) {

if (isset($field['alias'])) {
$alias = $field['alias'];
} else {
$alias = $primary_prefix;
}

$name = $field['name'];


if ($first) {
$first = false;
$as = 'id';
$distinct = 'DISTINCT';
} else {
$as = 'value';
$distinct = '';
$ordering = $alias.'.'.$name;
}

$m->model->query->select($distinct . ' ' . $m->model->db->qn($alias . '.' . $name) . ' as '. $as);
}
$m->model->query->order($m->model->db->qn($ordering) . ' ASC');
}

/** Where: Catalog Type */
$filter_catalog_type = $m->get('filter_catalog_type_id');

$m->model->query->select($m->model->db->qn($primary_prefix . '.' . $primary_key) . ' as id ');
$m->model->query->select($m->model->db->qn($primary_prefix . '.' . $name_key) . ' as value ');
if (is_array($filter_catalog_type)) {
$a = explode(',', $filter_catalog_type);
$m->model->query->where($m->model->db->qn($primary_prefix . '.' . 'catalog_type_id')
. ' IN (' . $a . ')');

} elseif ((int)$m->get('filter_catalog_type_id') == 0) {

if ((int)$m->get('filter_catalog_type_id') > 0) {
} else {
$m->model->query->where($m->model->db->qn($primary_prefix . '.' . 'catalog_type_id')
. ' = ' . (int)$m->get('filter_catalog_type_id'));
}

if ((int)$filter_check_published_status == 0) {
/** Where: Published Status */
$filter_check_published_status = $m->get('filter_check_published_status');

if (is_array($filter_catalog_type)) {
$a = explode(',', $filter_check_published_status);
$m->model->query->where($m->model->db->qn($primary_prefix . '.' . 'status')
. ' IN (' . $a . ')');

} elseif ((int)$filter_check_published_status == 0) {

} else {
$this->publishedStatus($m);
}

/** Menu ID */
/** Where: Extension Instance ID */
$filter_extension_instance_id = $m->get('filter_extension_instance_id');
if (is_array($filter_extension_instance_id)) {
$a = explode(',', filter_extension_instance_id);
$m->model->query->where($m->model->db->qn($primary_prefix . '.' . 'extension_instance_id')
. ' IN (' . $a . ')');

} elseif ((int)$filter_extension_instance_id == 0) {

} else {
$m->model->query->where($m->model->db->qn($primary_prefix . '.' . 'extension_instance_id')
. ' = ' . (int)$m->get('filter_extension_instance_id'));
}

/** Where: Menu ID */
$menu_id = null;
if (isset($parameters['menu_extension_catalog_type_id'])
&& (int) $parameters['menu_extension_catalog_type_id'] == 1300) {
@@ -306,8 +375,19 @@ public function getList($filter, $parameters)
$query_object = 'getListdata';
}

return $m->getData($query_object);

$query_results = $m->getData($query_object);

/**
echo '<br /><br /><br />';
echo $m->model->query->__toString($query_object);
echo '<pre>';
var_dump($query_results);
echo '</pre>';
echo '<br /><br /><br />';
**/

return $query_results;
}

/**
@@ -94,7 +94,7 @@ public function getGravatar($email, $size = 0, $type = 'mm', $rating = 'g', $ima
*/
public function getURL($catalog_id)
{
return Helpers::Catalog()->getURL($catalog_id);
return $this->getApplicationURL(Helpers::Catalog()->getURL($catalog_id));
}

/**

Large diffs are not rendered by default.

@@ -423,7 +423,9 @@ public function toSql($local = false, JDatabaseDriver $dbo = null)
if ($dbo === null) {
$dbo = JFactory::getDbo();
}
return $this->format($dbo->getDateFormat(), $local, false);

return $this->format('Y-m-d H:i:s', $local, false);
//Amy. Still does not work without deprecated classes since it always the same damn thing, just return it.return $this->format($dbo->getDateFormat(), $local, false);
}

/**