Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
assets/js/default.js000066600000002631150773114110010452 0ustar00/* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */ jQuery(function(t){t("select.auto-submit").bind("change",function(){t('form[name="adminForm"]').submit()});var i={};t.matchHeight=t.matchHeight||function(e,n,h){var r=t(window),a="resize orientationchange",o=e&&i[e];if(!o){o=i[e]={id:e,elements:n,deepest:h,match:function(){var i=this.revert(),e=0;t(this.elements).each(function(){e=Math.max(e,t(this).outerHeight())}).each(function(n){var h="outerHeight";if(i[n].css("box-sizing")=="border-box"){h="height"}var r=t(this),a=i[n],o=a.height()+(e-r[h]());a.css("min-height",o+"px")})},revert:function(){var i=[],e=this.deepest;t(this.elements).each(function(n){var h=e?t(this).find(e+":first"):t(this);i.push(h.css("min-height",""))});return i},remove:function(){r.unbind(a,s);this.revert();delete i[this.id]}};function s(){o.match()}r.bind(a,s)}return o};var e=[];t.onMediaQuery("(min-width: 480px) and (max-width: 959px)",{valid:function(){e=[];t.each([".categories .row > .width25",".categories .row > .width20",".categories > .width25",".categories > .width20",".subcategories > .width25",".subcategories > .width20",".items .row > .width25",".items .row > .width20"],function(i,n){for(var i=0,h=t(n),r=parseInt(h.length/2);iassets/index.html000066600000000036150773114110010046 0ustar00zoo.php000066600000001677150773114110006103 0ustar00path->register($path.'/assets', 'assets'); $zoo->path->register($path.'/controllers', 'controllers'); // add default js $zoo->document->addScript('assets:js/responsive.js'); $zoo->document->addScript('component.site:assets/js/default.js'); try { // load and dispatch application if ($application = $zoo->zoo->getApplication()) { $application->dispatch(); } else { return $zoo->error->raiseError(404, JText::_('Application not found')); } } catch (AppException $e) { $zoo->error->raiseError(500, $e); }router.php000066600000027074150773114110006613 0ustar00alias->category->translateIDToAlias((int) $query['category_id']); } unset($query['task'], $query['view'], $query['layout'], $query['category_id']); // pagination if (isset($query['page'])) { $segments[] = $query['page']; unset($query['page']); } } // alpha index $task = 'alphaindex'; if ((@$query['task'] == $task || @$query['view'] == $task) && isset($query['alpha_char'], $query['app_id'])) { $segments[] = $task; if (!($menu = $app->system->application->getMenu('site') and $menu instanceof JMenu and isset($query['Itemid']) and $item = $menu->getItem($query['Itemid']) and @$item->component == 'com_zoo' and $app_id = $item->params->get('application') and $query['app_id'] == $app_id)) { // Set app alias in the url only if we can't get the app_id from the menu item $segments[] = $app->alias->application->translateIDToAlias((int) $query['app_id']); } $segments[] = $query['alpha_char']; unset($query['task'], $query['view'], $query['alpha_char'], $query['app_id']); // pagination if (isset($query['page'])) { $segments[] = $query['page']; unset($query['page']); } } // tag $task = 'tag'; if ((@$query['task'] == $task || @$query['view'] == $task) && isset($query['tag'], $query['app_id'])) { $segments[] = $task; if (!($menu = $app->system->application->getMenu('site') and $menu instanceof JMenu and isset($query['Itemid']) and $item = $menu->getItem($query['Itemid']) and @$item->component == 'com_zoo' and $app_id = $item->params->get('application') and $query['app_id'] == $app_id)) { // Set app alias in the url only if we can't get the app_id from the menu item $segments[] = $app->alias->application->translateIDToAlias((int) $query['app_id']); } $segments[] = $query['tag']; unset($query['task'], $query['view'], $query['tag'], $query['app_id']); // pagination if (isset($query['page'])) { $segments[] = $query['page']; unset($query['page']); } } // item $task = 'item'; if (@$query['task'] == $task || @$query['view'] == $task) { if (@$query['task'] == $task && @$query['item_id']) { $segments[] = $task; $segments[] = $app->alias->item->translateIDToAlias((int) $query['item_id']); } unset($query['task'], $query['view'], $query['layout'], $query['item_id']); } // feed $task = 'feed'; if ((@$query['task'] == $task || @$query['view'] == $task) && isset($query['type'], $query['app_id'], $query['category_id'])) { $segments[] = $task; $segments[] = $query['type']; $segments[] = $app->alias->application->translateIDToAlias((int) $query['app_id']); if ($query['category_id']) { $segments[] = $app->alias->category->translateIDToAlias((int) $query['category_id']); } unset($query['task'], $query['view'], $query['type'], $query['app_id'], $query['category_id']); } // submission $task = 'submission'; if (((@$query['task'] == $task || @$query['view'] == $task) && @$query['layout'] == 'submission')) { $segments[] = $task; $segments[] = @$query['layout']; if (isset($query['submission_id'], $query['type_id'], $query['submission_hash'])) { $segments[] = $app->alias->submission->translateIDToAlias((int) $query['submission_id']); $segments[] = $query['type_id']; $segments[] = $query['submission_hash']; } if (isset($query['item_id'])) { $segments[] = $app->alias->item->translateIDToAlias((int) @$query['item_id']); } unset($query['task'], $query['view'], $query['layout'], $query['submission_id'], $query['type_id'], $query['submission_hash'], $query['item_id']); } // submission mysubmissions $task = 'submission'; if (((@$query['task'] == $task || @$query['view'] == $task) && @$query['layout'] == 'mysubmissions')) { $segments[] = $task; $segments[] = @$query['layout']; $segments[] = $app->alias->submission->translateIDToAlias((int) @$query['submission_id']); unset($query['task'], $query['view'], $query['layout'], $query['submission_id']); } $app->event->dispatcher->notify($app->event->create(null, 'application:sefbuildroute', array('segments' => &$segments, 'query' => &$query))); return $segments; } function ZooParseRoute($segments) { $app = App::getInstance('zoo'); // init vars $vars = array(); $count = count($segments); // fix segments (see JRouter::_decodeSegments) foreach (array_keys($segments) as $key) { $segments[$key] = str_replace(':', '-', $segments[$key]); } // frontpage (with optional pagination) $task = 'frontpage'; if ($count == 1 && $segments[0] == $task) { $vars['task'] = $task; } if ($count == 2 && $segments[0] == $task) { $vars['task'] = $task; $vars['page'] = (int) $segments[1]; } // category (with optional pagination) $task = 'category'; if ($count == 2 && $segments[0] == $task) { $vars['task'] = $task; $vars['category_id'] = (int) $app->alias->category->translateAliasToID($segments[1]); } if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; $vars['category_id'] = (int) $app->alias->category->translateAliasToID($segments[1]); $vars['page'] = (int) $segments[2]; } // alpha index (with optional pagination) $task = 'alphaindex'; if ($count == 2 && $segments[0] == $task && $menu_item = $app->menu->getActive()) { $vars['task'] = $task; $vars['alpha_char'] = (string) $segments[1]; $vars['app_id'] = $menu_item->params->get('application'); } if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; if (!$vars['app_id'] = (int) $app->alias->application->translateAliasToID($segments[1]) and $menu_item = $app->menu->getActive()) { $vars['app_id'] = $menu_item->params->get('application'); $vars['alpha_char'] = (string) $segments[1]; $vars['page'] = (int) $segments[2]; } else { $vars['alpha_char'] = (string) $segments[2]; } } if ($count == 4 && $segments[0] == $task) { $vars['task'] = $task; $vars['app_id'] = (int) $app->alias->application->translateAliasToID($segments[1]); $vars['alpha_char'] = (string) $segments[2]; $vars['page'] = (int) $segments[3]; } // tag (with optional pagination) $task = 'tag'; // if a menu item is set, avoid using app alias in the url if ($count == 2 && $segments[0] == $task && $menu_item = $app->menu->getActive()) { $vars['task'] = $task; $vars['app_id'] = $menu_item->params->get('application'); $vars['tag'] = (string) $segments[1]; } if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; if (!$vars['app_id'] = (int) $app->alias->application->translateAliasToID($segments[1]) and $menu_item = $app->menu->getActive()) { $vars['app_id'] = $menu_item->params->get('application'); $vars['tag'] = (string) $segments[1]; $vars['page'] = (int) $segments[2]; } else { $vars['tag'] = (string) $segments[2]; } } if ($count == 4 && $segments[0] == $task) { $vars['task'] = $task; $vars['app_id'] = (int) $app->alias->application->translateAliasToID($segments[1]); $vars['tag'] = (string) $segments[2]; $vars['page'] = (int) $segments[3]; } // item $task = 'item'; if ($count == 2 && $segments[0] == $task) { $vars['task'] = $task; $vars['item_id'] = (int) $app->alias->item->translateAliasToID($segments[1]); } // feed $task = 'feed'; if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; $vars['type'] = (string) $segments[1]; $vars['app_id'] = (int) $app->alias->application->translateAliasToID($segments[2]); } if ($count == 4 && $segments[0] == $task) { $vars['task'] = $task; $vars['type'] = (string) $segments[1]; $vars['app_id'] = (int) $app->alias->application->translateAliasToID($segments[2]); $vars['category_id'] = (int) $app->alias->category->translateAliasToID($segments[3]); } // submission $task = 'submission'; $layout = 'submission'; if ($count == 2 && $segments[0] == $task && $segments[1] == $layout) { $vars['task'] = $task; $vars['layout'] = (string) $segments[1]; } if ($count == 5 && $segments[0] == $task && $segments[1] == $layout) { $vars['task'] = $task; $vars['layout'] = (string) $segments[1]; $vars['submission_id'] = (int) $app->alias->submission->translateAliasToID($segments[2]); $vars['type_id'] = (string) $segments[3]; $vars['submission_hash'] = (string) $segments[4]; } if ($count == 6 && $segments[0] == $task && $segments[1] == $layout) { $vars['task'] = $task; $vars['layout'] = (string) $segments[1]; $vars['submission_id'] = (int) $app->alias->submission->translateAliasToID($segments[2]); $vars['type_id'] = (string) $segments[3]; $vars['submission_hash'] = (string) $segments[4]; $vars['item_id'] = (int) $app->alias->item->translateAliasToID($segments[5]); } // submission mysubmissions $task = 'submission'; $layout = 'mysubmissions'; if ($count == 2 && $segments[0] == $task && $segments[1] == $layout) { $vars['task'] = $task; $vars['layout'] = (string) $segments[1]; } if ($count == 3 && $segments[0] == $task && $segments[1] == $layout) { $vars['task'] = $task; $vars['layout'] = (string) $segments[1]; $vars['submission_id'] = (int) $app->alias->submission->translateAliasToID($segments[2]); } // try to retrieve vars from menu item if (empty($vars)) { if (($count == 0 || $count == 1 && is_numeric($segments[0])) && $menu_item = $app->menu->getActive()) { $vars['task'] = @$menu_item->query['view']; switch ($vars['task']) { case 'frontpage': if ($count == 1) { $vars['page'] = (int) $segments[0]; } break; case 'category': if ($count == 1) { $vars['page'] = (int) $segments[0]; $vars['category_id'] = @$menu_item->query['category_id']; } break; } } } $app->event->dispatcher->notify($app->event->create(null, 'application:sefparseroute', array('segments' => &$segments, 'vars' => &$vars))); return $vars; }views/submission/tmpl/submission.xml000066600000001670150773114110013775 0ustar00 Submission Displays a submission form for a single item.
views/submission/tmpl/submission.php000066600000000367150773114110013766 0ustar00views/submission/tmpl/mysubmissions.php000066600000000367150773114110014517 0ustar00 My Submissions Displays an overview of users submitted articles.
views/submission/index.html000066600000000036150773114110012074 0ustar00views/index.html000066600000000036150773114110007701 0ustar00views/item/tmpl/element.xml000066600000000127150773114110011772 0ustar00 views/item/tmpl/index.html000066600000000036150773114110011613 0ustar00views/item/tmpl/element.php000066600000001030150773114110011753 0ustar00app->document->addStylesheet('assets:css/ui.css'); // load element require_once($this->app->path->path('component.admin:views/item/tmpl/element.php')); ?> views/item/tmpl/item.xml000066600000001017150773114110011276 0ustar00
views/item/index.html000066600000000036150773114110010637 0ustar00views/frontpage/tmpl/index.html000066600000000036150773114110012642 0ustar00views/frontpage/tmpl/frontpage.xml000066600000000665150773114110013364 0ustar00
views/frontpage/index.html000066600000000036150773114110011666 0ustar00views/category/tmpl/index.html000066600000000036150773114110012472 0ustar00views/category/tmpl/category.xml000066600000001070150773114110013033 0ustar00
views/category/index.html000066600000000036150773114110011516 0ustar00index.html000066600000000036150773114110006544 0ustar00renderer/index.html000066600000000036150773114110010352 0ustar00renderer/element/pipe.php000066600000001314150773114110011454 0ustar00config->get('name'); } // create class attribute $class = 'element element-'.$element->getElementType().($params['first'] ? ' first' : '').($params['last'] ? ' last' : ''); ?> render($params); ?> config->get('name'); } // create class attribute $class = 'element element-'.$element->getElementType().($params['first'] ? ' first' : '').($params['last'] ? ' last' : ''); ?> render($params); ?> '; $label .= ($params['altlabel']) ? $params['altlabel'] : $element->config->get('name'); $label .= ''; } // create class attribute $class = 'element element-'.$element->getElementType().($params['first'] ? ' first' : '').($params['last'] ? ' last' : ''); ?>

render($params); ?>

renderer/element/default.php000066600000000752150773114110012150 0ustar00config->get('name'); } // render element echo $label.' '.$element->render($params).' ';renderer/element/submission/index.html000066600000000036150773114110014176 0ustar00renderer/element/submission/block.php000066600000002225150773114110014006 0ustar00app->data->create($params); // add tooltip $tooltip = ''; if ($params->get('show_tooltip') && ($description = $element->config->get('description'))) { $tooltip = ' class="hasTip" title="'.JText::_($description).'"'; } // create label $label = ''; $label .= JText::_($params->get('altlabel') ? $params->get('altlabel') : $element->config->get('name')); $label .= ''; // create error $error = ''; if (@$element->error) { $error = '

'.(string) $element->error.'

'; } // create class attribute $class = 'element element-'.$element->getElementType().($params->get('first') ? ' first' : '').($params->get('last') ? ' last' : '').($params->get('required') ? ' required' : '').(@$element->error ? ' error' : ''); $element->loadAssets(); ?>
renderSubmission($params).$error; ?>
renderer/element/index.html000066600000000036150773114110012003 0ustar00renderer/element/comma.php000066600000001315150773114110011614 0ustar00config->get('name'); } // create class attribute $class = 'element element-'.$element->getElementType().($params['first'] ? ' first' : '').($params['last'] ? ' last' : ''); ?> render($params); ?> renderer/element/list.php000066600000001317150773114110011475 0ustar00'; $label .= ($params['altlabel']) ? $params['altlabel'] : $element->config->get('name'); $label .= ': '; } // create class attribute $class = 'element element-'.$element->getElementType().($params['first'] ? ' first' : '').($params['last'] ? ' last' : ''); ?>
  • render($params); ?>
  • renderer/element/block.php000066600000001307150773114110011613 0ustar00'; $label .= ($params['altlabel']) ? $params['altlabel'] : $element->config->get('name'); $label .= ''; } // create class attribute $class = 'element element-'.$element->getElementType().($params['first'] ? ' first' : '').($params['last'] ? ' last' : ''); ?>
    render($params); ?>
    renderer/element/inline.php000066600000001245150773114110012000 0ustar00config->get('name'); } // create class attribute $class = 'element element-'.$element->getElementType().($params['first'] ? ' first' : '').($params['last'] ? ' last' : ''); ?> render($params); ?> controllers/default.php000066600000044763150773114110011271 0ustar00application = $this->app->zoo->getApplication(); // get Joomla application $this->joomla = $this->app->system->application; // get params $this->params = $this->joomla->getParams(); // get pathway $this->pathway = $this->joomla->getPathway(); // registers tasks $this->registerTask('frontpage', 'category'); } /* Function: display View method for MVC based architecture Returns: Void */ public function display($cachable = false, $urlparams = false) { // execute task $this->taskMap['display'] = null; $this->taskMap['__default'] = null; $this->execute($this->app->request->getCmd('view')); } /* Function: callElement Element callback method Returns: Void */ public function callElement() { // get request vars $element = $this->app->request->getCmd('element', ''); $method = $this->app->request->getCmd('method', ''); $args = $this->app->request->getVar('args', array(), 'default', 'array'); $item_id = (int) $this->app->request->getInt('item_id', 0); // get user $user = $this->app->user->get(); // get item $item = $this->app->table->item->get($item_id); // raise 404 if item does not exist or is not published if (empty($item) || !$item->isPublished()) { return $this->app->error->raiseError(404, JText::_('Item not found')); } // raise warning when item can not be accessed if (!$item->canAccess($user)) { return $this->app->error->raiseError(403, JText::_('Unable to access item')); } // get element and execute callback method if ($element = $item->getElement($element)) { $element->callback($method, $args); } } public function item() { // get request vars $item_id = (int) $this->app->request->getInt('item_id', $this->params->get('item_id', 0)); // get item $this->item = $this->app->table->item->get($item_id); // get user $user = $this->app->user->get(); // raise 404 if item does not exist or is not published if (empty($this->item) || !$this->item->isPublished()) { return $this->app->error->raiseError(404, JText::_('Item not found')); } // raise 403 if user is not allowed to view item if (!$this->item->canAccess($user)) { // Show error message if logged in and cannot access item if ($user->id) { return $this->app->error->raiseWarning(403, JText::_('Unable to access item')); } // redirect to login for guest users $return = urlencode(base64_encode($this->app->route->item($this->item, false))); $link = JRoute::_(sprintf('index.php?option=com_users&view=login&return=%s', $return), false); $this->setRedirect($link, JText::_('Unable to access item'), 'error'); return $this->redirect(); } // add canonical if ($this->app->system->document instanceof JDocumentHTML) { $this->app->system->document->addHeadLink(JRoute::_($this->app->route->item($this->item, false), true, -1), 'canonical'); $headData = $this->app->system->document->getHeadData(); foreach ($headData['links'] as $key => $value) { if($value['relation'] == 'canonical' && $key != JRoute::_($this->app->route->item($this->item, false), true, -1)) { unset($headData['links'][$key]); } } $this->app->system->document->setHeadData($headData); } // get category_id $category_id = (int) $this->app->request->getInt('category_id', $this->item->getPrimaryCategoryId()); // create item pathway $itemid = $this->params->get('item_id'); if ($this->item->id != $itemid) { $categories = $this->application->getCategoryTree(true); if (isset($categories[$category_id])) { $category = $categories[$category_id]; $addpath = false; $catid = $this->params->get('category'); foreach ($category->getPathway() as $cat) { if (!$catid || $addpath) { $link = JRoute::_($this->app->route->category($cat)); $this->pathway->addItem($cat->name, $link); } if ($catid && $catid == $cat->id) { $addpath = true; } } } $this->pathway->addItem($this->item->name, $this->app->route->item($this->item)); } // update hit count $this->item->hit(); // get page title, if exists $title = $this->item->getParams()->get('metadata.title'); $title = empty($title) ? $this->item->name : $title; if ($menu = $this->app->menu->getActive() and @$menu->query['view'] == 'item' and $this->app->parameter->create($menu->params)->get('item_id') == $itemid) { if ($page_title = $this->app->parameter->create($menu->params)->get('page_title')) { $title = $page_title; } } // set metadata $this->app->document->setTitle($this->app->zoo->buildPageTitle($title)); if ($this->app->system->config->get('MetaAuthor')) $this->app->document->setMetadata('author', $this->item->getAuthor()); if ($description = $this->item->getParams()->get('metadata.description')) $this->app->document->setDescription($description); foreach (array('keywords', 'author', 'robots') as $meta) { if ($value = $this->item->getParams()->get("metadata.$meta")) $this->app->document->setMetadata($meta, $value); } // get template and params if (!$this->template = $this->application->getTemplate()) { return $this->app->error->raiseError(500, JText::_('No template selected')); } $this->params = $this->item->getParams('site'); // set renderer $this->renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath())); // display view $this->getView('item')->addTemplatePath($this->template->getPath())->setLayout('item')->display(); } public function submission() { // perform the request task $this->request->set('task', $this->request->get('layout', '')); $this->app->dispatch('submission'); } public function category() { // get request vars $page = $this->app->request->getInt('page', 1); $category_id = (int) $this->app->request->getInt('category_id', $this->params->get('category')); // init vars $this->categories = $this->application->getCategoryTree(true, $this->app->user->get(), true); // raise 404 if category does not exist if ($category_id && !$this->app->table->category->get($category_id)) { return $this->app->error->raiseError(404, JText::_('Category not found')); } // raise warning when category can not be accessed if (!isset($this->categories[$category_id])) { return $this->app->error->raiseError(403, JText::_('Unable to access category')); } $this->category = $this->categories[$category_id]; $params = $category_id ? $this->category->getParams('site') : $this->application->getParams('frontpage'); $this->item_order = $params->get('config.item_order'); $layout = $category_id == 0 ? 'frontpage' : 'category'; $items_per_page = $params->get('config.items_per_page', 15); $offset = max(($page - 1) * $items_per_page, 0); // get categories and items $this->items = $this->app->table->item->getByCategory($this->application->id, $category_id, true, null, $this->item_order, $offset, $items_per_page); $item_count = $this->category->id == 0 ? $this->app->table->item->getItemCountFromCategory($this->application->id, $category_id, true) : $this->category->itemCount(); // set categories to display $this->selected_categories = $this->category->getChildren(); // get item pagination $this->pagination = $this->app->pagination->create($item_count, $page, $items_per_page, 'page', 'app'); $this->pagination->setShowAll($items_per_page == 0); $this->pagination_link = $layout == 'category' ? $this->app->route->category($this->category, false) : $this->app->route->frontpage($this->application->id); // create pathway $addpath = false; $catid = $this->params->get('category'); foreach ($this->category->getPathway() as $cat) { if (!$catid || $addpath) { $this->pathway->addItem($cat->name, $this->app->route->category($cat)); } if ($catid && $catid == $cat->id) { $addpath = true; } } // get metadata $title = $params->get('metadata.title') ? $params->get('metadata.title') : ($category_id ? $this->category->name : ''); $description = $params->get('metadata.description'); $keywords = $params->get('metadata.keywords'); if ($menu = $this->app->menu->getActive() and in_array(@$menu->query['view'], array('category', 'frontpage')) and $menu_params = $this->app->parameter->create($menu->params) and $menu_params->get('category') == $category_id) { if ($page_title = $menu_params->get('page_title') or $page_title = $menu->title) { $title = $page_title; } if ($page_description = $menu_params->get('menu-meta_description')) { $description = $page_description; } if ($page_keywords = $menu_params->get('menu-meta_keywords')) { $keywords = $page_keywords; } } // set page title if ($title) { $this->app->document->setTitle($this->app->zoo->buildPageTitle($title)); } if ($description) { $this->app->document->setDescription($description); } if ($keywords) { $this->app->document->setMetadata('keywords', $keywords); } // set metadata foreach (array('author', 'robots') as $meta) { if ($value = $params->get("metadata.$meta")) $this->app->document->setMetadata($meta, $value); } // add feed links if ($params->get('config.show_feed_link') && $this->app->system->document instanceof JDocumentHTML) { if ($alternate = $params->get('config.alternate_feed_link')) { $this->app->document->addHeadLink($alternate, 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); } else { $this->app->document->addHeadLink(JRoute::_($this->app->route->feed($this->category, 'rss')), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0')); $this->app->document->addHeadLink(JRoute::_($this->app->route->feed($this->category, 'atom')), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0')); } } // set alphaindex if ($params->get('template.show_alpha_index')) { $this->alpha_index = $this->_getAlphaindex(); } // set template and params if (!$this->template = $this->application->getTemplate()) { return $this->app->error->raiseError(500, JText::_('No template selected')); } $this->params = $params; // set renderer $this->renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath())); // display view $this->getView($layout)->addTemplatePath($this->template->getPath())->setLayout($layout)->display(); } public function alphaindex() { // get request vars $page = $this->app->request->getInt('page', 1); $this->alpha_char = $this->app->request->getString('alpha_char', ''); // get params $params = $this->application->getParams('site'); $items_per_page = $params->get('config.items_per_page', 15); $this->item_order = $params->get('config.item_order'); $add_alpha_index = $params->get('config.alpha_index', 0); // get categories $this->categories = $add_alpha_index == 1 || $add_alpha_index == 3 ? $this->application->getCategoryTree(true, $this->app->user->get(), true) : array(); // set alphaindex $this->alpha_index = $this->_getAlphaindex(); $this->alpha_char = empty($this->alpha_char) ? $this->alpha_index->getOther() : $this->alpha_index->getChar($this->alpha_char); // get items $this->items = array(); if ($add_alpha_index == 2 || $add_alpha_index == 3) { $table = $this->app->table->item; if ($this->alpha_char == $this->alpha_index->getOther()) { $this->items = $table->getByCharacter($this->application->id, $this->alpha_index->getIndex(), true, true, null, $this->item_order); } else { $this->items = $table->getByCharacter($this->application->id, $this->alpha_char, false, true, null, $this->item_order); } } // get item pagination $this->pagination = $this->app->pagination->create(count($this->items), $page, $items_per_page, 'page', 'app'); $this->pagination->setShowAll($items_per_page == 0); $this->pagination_link = $this->app->route->alphaindex($this->application->id, $this->alpha_char); // slice out items if (!$this->pagination->getShowAll()) { $this->items = array_slice($this->items, $this->pagination->limitStart(), $items_per_page); } // set category and categories to display if (isset($this->categories[0])) { $this->category = $this->categories[0]; } $this->selected_categories = $this->alpha_index->getObjects($this->alpha_char, 'category'); // create pathway $this->pathway->addItem(JText::_('Alpha Index'), JRoute::_($this->app->route->alphaindex($this->application->id, $this->alpha_char))); // set template and params if (!$this->template = $this->application->getTemplate()) { return $this->app->error->raiseError(500, JText::_('No template selected')); } $this->params = $params; // set renderer $this->renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath())); // display view $this->getView('alphaindex')->addTemplatePath($this->template->getPath())->setLayout('alphaindex')->display(); } public function tag() { // get request vars $page = $this->app->request->getInt('page', 1); $this->tag = $this->app->request->getString('tag', ''); // get params $params = $this->application->getParams('site'); $items_per_page = $params->get('config.items_per_page', 15); $this->item_order = $params->get('config.item_order'); // get categories and items $this->categories = $this->application->getCategoryTree(true); $this->items = $this->app->table->item->getByTag($this->application->id, $this->tag, true, null, $this->item_order); // get item pagination $this->pagination = $this->app->pagination->create(count($this->items), $page, $items_per_page, 'page', 'app'); $this->pagination->setShowAll($items_per_page == 0); $this->pagination_link = $this->app->route->tag($this->application->id, $this->tag); // slice out items if (!$this->pagination->getShowAll()) { $this->items = array_slice($this->items, $this->pagination->limitStart(), $items_per_page); } // set alphaindex if ($params->get('template.show_alpha_index')) { $this->alpha_index = $this->_getAlphaindex(); } // set metadata $this->app->document->setTitle($this->app->zoo->buildPageTitle($this->tag)); // create pathway $this->pathway->addItem(JText::_('Tags').': '.$this->tag, JRoute::_($this->app->route->tag($this->application->id, $this->tag))); // get template and params if (!$this->template = $this->application->getTemplate()) { return $this->app->error->raiseError(500, JText::_('No template selected')); } $this->params = $params; // set renderer $this->renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath())); // display view $this->getView('tag')->addTemplatePath($this->template->getPath())->setLayout('tag')->display(); } public function feed() { // get request vars $category_id = (int) $this->app->request->getInt('category_id', $this->params->get('category')); // get params $all_categories = $this->application->getCategoryTree(true); // raise warning when category can not be accessed if (!isset($all_categories[$category_id])) { return $this->app->error->raiseWarning(404, JText::_('Unable to access category')); } $category = $all_categories[$category_id]; $params = $category_id ? $category->getParams('site') : $this->application->getParams('frontpage'); $show_feed_link = $params->get('config.show_feed_link', 0); $feed_title = $params->get('config.feed_title', ''); // raise error when feed is disabled if (empty($show_feed_link)) { return $this->app->error->raiseError(404, JText::_('Unable to access feed')); } // get feed items from category if ($category_id) { $categories = $category->getChildren(true); } $categories[$category->id] = $category; $feed_limit = $this->app->system->config->get('feed_limit'); $feed_items = $this->app->table->item->getByCategory($this->application->id, array_keys($categories), true, null, array('_itempublish_up', '_reversed'), 0, $feed_limit, true); // set title if ($feed_title) { $this->app->system->document->setTitle($this->app->zoo->buildPageTitle(html_entity_decode($this->getView()->escape($feed_title)))); } // set feed link $this->app->system->document->setLink(JRoute::_($category_id ? $this->app->route->category($category) : $this->app->route->frontpage($this->application->id))); // set feed description $this->app->system->document->setDescription(html_entity_decode($this->getView()->escape($this->app->system->document->getDescription()))); // set renderer $renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->application->getTemplate()->getPath())); foreach ($feed_items as $feed_item) { // create feed item $item = new JFeedItem(); $item->title = html_entity_decode($this->getView()->escape($feed_item->name)); $item->link = $this->app->route->item($feed_item); $item->date = $feed_item->created; $item->author = $feed_item->getAuthor(); $item->description = $this->_relToAbs($renderer->render('item.feed', array('item' => $feed_item))); // add to feed document $this->app->system->document->addItem($item); } } protected function _getAlphaindex() { return $this->app->application->getAlphaIndex($this->application); } protected function _relToAbs($text) { // convert relative to absolute url $base = JURI::base(); $text = preg_replace("/(href|src)=\"(?!http|ftp|https|mailto)(?!\/)([^\"]*)\"/", "$1=\"$base\$2\"", $text); $base = JURI::getInstance()->toString(array('scheme', 'user', 'pass', 'host', 'port')); $text = preg_replace("/(href|src)=\"(?!http|ftp|https|mailto)([^\"]*)\"/", "$1=\"$base\$2\"", $text); return $text; } // @deprecated as of 2.5.7 protected function _buildPageTitle($title) { return $this->app->zoo->buildPageTitle($title); } } /* Class: DefaultControllerException */ class DefaultControllerException extends AppException {} controllers/submission.php000066600000050673150773114110012035 0ustar00user = $this->app->user->get(); // get item id $this->item_id = $this->app->request->getInt('item_id'); // get pathway $this->pathway = $this->app->system->application->getPathway(); // get submission info from Request if (!$submission_id = $this->app->request->getInt('submission_id')) { // else get submission info from menu item if ($menu = $this->app->menu->getActive()) { $this->menu_params = $this->app->parameter->create($menu->params); $submission_id = $this->menu_params->get('submission'); } } // set submission if ($this->submission = $this->app->table->submission->get((int) $submission_id)) { // set application $this->application = $this->submission->getApplication(); // set template $this->template = $this->application->getTemplate(); // set session form key $this->session_form_key = self::SESSION_PREFIX . 'SUBMISSION_FORM_' . $this->submission->id; } // load administration language files $this->app->system->language->load('', JPATH_ADMINISTRATOR, null, true); $this->app->system->language->load('com_zoo', JPATH_ADMINISTRATOR, null, true); } public function mysubmissions() { try { $this->_checkConfig(); if (!$this->app->user->canAccess($this->user, 1)) { throw new SubmissionControllerException('Insufficient User Rights.'); } // get request vars $order = $this->app->request->getCmd('order', $this->app->system->application->getParams()->get('order', 0)); $limit = SubmissionController::PAGINATION_LIMIT; $state_prefix = $this->option.'_'.$this->application->id.'.submission.'.$this->submission->id; $this->filter_type = $this->app->system->application->getUserStateFromRequest($state_prefix.'.filter_type', 'filter_type', '', 'string'); $search = $this->app->string->strtolower($this->app->system->application->getUserStateFromRequest($state_prefix.'.search', 'search', '', 'string')); $this->page = $this->app->request->getInt('page', 1); $limitstart = (max(array($this->page, 1)) - 1) * $limit; $this->types = $this->submission->getSubmittableTypes(); // set renderer $this->renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath())); // type filter if (empty($this->filter_type)) { $type = $this->types; } else { $type = $this->filter_type; } $this->items = $this->app->table->item->getByUser($this->application->id, $this->user->id, $type, $search, $order, $limitstart, $limit); $this->pagination = $this->app->pagination->create($this->app->table->item->getItemCountByUser($this->application->id, $this->user->id, $type, $search), $this->page, $limit, 'page', 'app'); // type select if (count($this->types) > 1) { $options = array($this->app->html->_('select.option', '', '- '.JText::_('Select Type').' -')); foreach ($this->types as $id => $type) { $options[] = $this->app->html->_('select.option', $id, $type->name); } $this->lists['select_type'] = $this->app->html->_('select.genericlist', $options, 'filter_type', 'class="inputbox auto-submit"', 'value', 'text', $this->filter_type); } // add search $this->lists['search'] = $search; // Can a new item be added? $this->show_add = $this->_checkMaxSubmissions(); // display view $this->getView('submission')->addTemplatePath($this->template->getPath())->setLayout('mysubmissions')->display(); } catch (SubmissionControllerException $e) { // raise warning on exception $this->app->error->raiseWarning(0, (string) JText::_($e)); } } public function submission() { try { $this->_init(); // on edit: can access and is owner if frontend edit is disabled for the item if ($this->item->id && (!$this->item->canAccess($this->user) || (!$this->submission->isItemEditSubmission() && $this->item->created_by != $this->user->id))) { throw new AppControllerException('You are not allowed to edit this item.'); } // If it's a new item and the user has reached the max number of submissions, trigger error if (!$this->item->id && !$this->_checkMaxSubmissions()) { return $this->app->error->raiseNotice(0, 'You have reached your maximum number of submissions'); } // bind data from sessions post data $this->errors = 0; if ($post = unserialize($this->app->system->application->getUserState($this->session_form_key))) { // remove post data from session $this->app->system->application->setUserState($this->session_form_key, null); // bind data $this->errors = $this->_bind($post); } $this->cancelUrl = false; if ($this->redirectTo) { // build cancel url $this->cancelUrl = $this->_getRedirectLink(); // build pathway $this->pathway->addItem($this->item->id ? JText::_('Edit Submission') : JText::_('Add Submission')); } // build captcha $this->captcha = false; if ($plugin = $this->submission->getParams()->get('captcha', false) and (!$this->submission->getParams()->get('captcha_guest_only', 0) || !$this->app->user->get()->id)) { $this->captcha = JCaptcha::getInstance($plugin); } // display view $this->getView('submission')->addTemplatePath($this->template->getPath())->setLayout('submission')->display(); } catch (SubmissionControllerException $e) { // raise warning on exception $this->app->error->raiseWarning(0, (string) JText::_($e)); } } public function save() { // check for request forgeries $this->app->session->checkToken() or jexit('Invalid Token'); // init vars $post = $this->app->request->get('post:', 'array'); $msg = ''; try { $this->_init(); // set name on new item if (!$edit = (bool) $this->item->id) { $this->item->name = JText::_('Submitted Item'); } // on edit: can access and is owner if frontend edit is disabled for the item if ($edit && (!$this->item->canAccess($this->user) || (!$this->submission->isItemEditSubmission() && $this->item->created_by != $this->user->id))) { throw new AppControllerException('You are not allowed to make changes to this item.'); } // If it's a new item and the user has reached the max number of submissions, trigger error if (!$this->item->id && !$this->_checkMaxSubmissions()) { throw new AppControllerException('You have reached your maximum number of submissions'); } // get element data from post if (isset($post['elements'])) { // filter element data if (!$this->submission->isInTrustedMode() && !$this->app->user->isJoomlaAdmin($this->user)) { $this->app->request->setVar('elements', $this->app->submission->filterData($post['elements'])); $post = $this->app->request->get('post:', 'array'); } // merge elements into post $post = array_merge($post, $post['elements']); } // merge userfiles element data with post data foreach ($_FILES as $key => $userfile) { if (strpos($key, 'elements_') === 0) { $post[str_replace('elements_', '', $key)]['userfile'] = $userfile; } } $item_name = $this->item->name; $error = $this->_bind($post); // Check captcha if ($plugin = $this->submission->getParams()->get('captcha', false) and (!$this->submission->getParams()->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) { $captcha = JCaptcha::getInstance($plugin); if (!$captcha->checkAnswer(@$post['captcha'])) { $error = $captcha->getError(); if (!($error instanceof Exception)) { $error = new JException($error); } // raise warning on exception $this->app->error->raiseWarning(0, JText::_('ZOO_CHECK_CAPTCHA') . ' - ' . JText::_($error)); } } // save item if it is valid if (!$error) { // set alias if (!$edit || $item_name != $this->item->name) { $this->item->alias = $this->app->alias->item->getUniqueAlias($this->item->id, $this->app->string->sluggify($this->item->name)); } // unpublish item in none trusted state if (!$this->submission->isInTrustedMode() && !in_array('_itemstate', array_keys($this->elements_config))) { $this->item->state = 0; } // set modified $this->item->modified = $this->app->date->create()->toSQL(); $this->item->modified_by = $this->user->get('id'); // enforce time limit on submissions if (!$edit && !$this->submission->isInTrustedMode()) { $timestamp = time(); if ($timestamp < $this->app->system->session->get('ZOO_LAST_SUBMISSION_TIMESTAMP') + SubmissionController::TIME_BETWEEN_PUBLIC_SUBMISSIONS) { $this->app->system->application->setUserState($this->session_form_key, serialize($post)); throw new SubmissionControllerException('You are submitting too fast, please try again in a few moments.'); } $this->app->system->session->set('ZOO_LAST_SUBMISSION_TIMESTAMP', $timestamp); } // deprecated as of version 2.5.7 call to doUpload, use before save event instead foreach ($this->elements_config as $element) { if (($element = $this->item->getElement($element['element'])) && $element instanceof iSubmissionUpload) { $element->doUpload(); } } // Add primary category if no primary category is set (i.e: no itemcategory element present) $primary_category = $this->item->getPrimaryCategory(); if (!$edit && empty($primary_category) && $category = $this->submission->getForm($this->type->id)->get('category')) { $this->item->getParams()->set('config.primary_category', $category); } // trigger before save event $this->app->event->dispatcher->notify($this->app->event->create($this->submission, 'submission:beforesave', array('item' => $this->item, 'new' => !$edit))); // save item $this->app->table->item->save($this->item); // save to default category if (!$edit && ($category = $this->submission->getForm($this->type->id)->get('category'))) { $this->app->category->saveCategoryItemRelations($this->item, array($category)); } // set redirect message $msg = JText::_($edit ? 'Submission saved' : ($this->submission->isInTrustedMode() ? 'Thanks for your submission.' : 'Thanks for your submission. It will be reviewed before being posted on the site.')); // trigger saved event $this->app->event->dispatcher->notify($this->app->event->create($this->submission, 'submission:saved', array('item' => $this->item, 'new' => !$edit))); } else { // add post data to session if form is not valid $this->app->system->application->setUserState($this->session_form_key, serialize($post)); } } catch (SubmissionControllerException $e) { $error = true; // raise warning on exception $this->app->error->raiseWarning(0, (string) JText::_($e)); } catch (AppException $e) { $error = true; // raise warning on exception $this->app->error->raiseWarning(0, JText::_('There was an error saving your submission, please try again later.')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, (string) $e); } } // If an error is found, redirect to the edit form itself $link = $error ? $this->app->route->submission($this->submission, $this->type->id, null, $this->item_id, $this->redirectTo) : $this->_getRedirectLink(); $this->setRedirect(JRoute::_($link, false), $msg); } public function remove() { // init vars $msg = null; try { $this->_checkConfig(); if (!$this->submission->isInTrustedMode()) { throw new AppControllerException('The submission is not in Trusted Mode.'); } // get item table and delete item $table = $this->app->table->item; $item = $table->get($this->item_id); // is current user the item owner and does the user have sufficient user rights if ($item->id && (!$item->canAccess($this->user) || $item->created_by != $this->user->id)) { throw new AppControllerException('You are not allowed to make changes to this item.'); } $table->delete($item); // set redirect message $msg = JText::_('Submission Deleted'); // trigger deleted event $this->app->event->dispatcher->notify($this->app->event->create($item, 'submission:deleted')); } catch (AppException $e) { // raise warning on exception $this->app->error->raiseWarning(0, JText::_('There was an error deleting your submission, please try again later.')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, (string) JText::_($e)); } } $this->setRedirect(JRoute::_($this->app->route->mysubmissions($this->submission), false), $msg); } public function loadtags() { // get request vars $tag = $this->app->request->getString('tag', ''); echo $this->app->tag->loadTags($this->application->id, $tag); } protected function _checkConfig() { if (!$this->application || !$this->submission) { throw new SubmissionControllerException('Submissions are not configured correctly.'); } if (!$this->submission->getState()) { throw new SubmissionControllerException('Submissions are disabled.'); } if (!$this->submission->canAccess($this->user)) { throw new SubmissionControllerException('Insufficient User Rights.'); } } protected function _checkMaxSubmissions() { $max_submissions = $this->submission->getParams()->get('max_submissions', '0'); // Infinite: all ok if ($max_submissions == '0') { return true; } $current_submissions = $this->app->table->item->getItemCountByUser($this->application->id, $this->user->id); return $current_submissions < $max_submissions; } protected function _init() { //init vars $type_id = $this->app->request->getCmd('type_id'); $hash = $this->app->request->getCmd('submission_hash'); $this->redirectTo = urldecode($this->app->request->getString('redirect', '')); // check config $this->_checkConfig(); // get submission info from request if ($type_id) { if ($hash != $this->app->submission->getSubmissionHash($this->submission->id, $type_id, $this->item_id)) { throw new SubmissionControllerException('Hashes did not match.'); } // else get submission info from active menu } elseif ($this->menu_params) { $type_id = $this->menu_params->get('type'); // remove item_id (menu item may not have an item_id) $this->item_id = null; } // set type $this->type = $this->submission->getType($type_id); // check type if (!$this->type) { throw new SubmissionControllerException('Submissions are not configured correctly.'); } // set hash $this->hash = $hash ? $hash : $this->app->submission->getSubmissionHash($this->submission->id, $this->type->id, $this->item_id); // set layout $this->layout = $this->submission->getForm($this->type->id)->get('layout', ''); // check layout if (empty($this->layout)) { throw new SubmissionControllerException('Submission is not configured correctly.'); } // set renderer $this->renderer = $this->app->renderer->create('submission')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath())); // set layout path $this->layout_path = 'item.'; if ($this->renderer->pathExists('item/'.$this->type->id)) { $this->layout_path .= $this->type->id.'.'; } $this->layout_path .= $this->layout; // get positions $positions = $this->renderer->getConfig('item')->get($this->application->getGroup().'.'.$this->type->id.'.'.$this->layout, array()); // get elements from positions $this->elements_config = array(); foreach ($positions as $position) { foreach ($position as $element) { $this->elements_config[$element['element']] = $element; } } // get item if (!$this->item_id || !($this->item = $this->app->table->item->get($this->item_id))) { $now = $this->app->date->create()->toSQL(); $this->item = $this->app->object->create('Item'); $this->item->application_id = $this->application->id; $this->item->type = $this->type->id; $this->item->publish_up = $now; $this->item->publish_down = $this->app->database->getNullDate(); $this->item->access = $this->app->joomla->getDefaultAccess(); $this->item->created = $now; $this->item->created_by = $this->user->get('id'); $this->item->created_by_alias = ''; $this->item->state = 0; $this->item->searchable = true; $this->item->getParams() ->set('config.enable_comments', true) ->set('config.primary_category', 0); } } protected function _bind($post = array()) { $errors = 0; foreach ($this->elements_config as $element_data) { try { if (($element = $this->item->getElement($element_data['element']))) { // get params $params = $this->app->data->create(array_merge(array('trusted_mode' => $this->submission->isInTrustedMode()), $element_data)); $element->bindData($element->validateSubmission($this->app->data->create(@$post[$element->identifier]), $params)); } } catch (AppValidatorException $e) { if (isset($element)) { $element->error = $e; $element->bindData(@$post[$element->identifier]); } $errors++; } } return $errors; } protected function _getRedirectLink() { // Check redirect link switch ($this->redirectTo) { case null: // Check menu item for redirect if ($menu = $this->app->menu->getActive()) { if ($menu_item_id = $this->app->parameter->create($menu->params)->get('redirect', false)) { return JRoute::_('index.php?Itemid=' . $menu_item_id, false); } } return $this->app->route->submission($this->submission, $this->type->id, null, $this->item_id, $this->redirectTo); case 'mysubmissions': // redirect to list of submissions return $this->app->route->mysubmissions($this->submission); case 'itemedit': // Redirect to the item if ($this->item->getState() == 1) { return $this->app->route->item($this->item); } else { return $this->app->route->submission($this->submission, $this->type->id, null, $this->item_id); } default: // Custom redirect return base64_decode($this->redirectTo); } } } /* Class: SubmissionControllerException */ class SubmissionControllerException extends AppException {}controllers/comment.php000066600000032214150773114110011273 0ustar00user = $this->app->user->get(); // get application $this->application = $this->app->zoo->getApplication(); // get comment params $this->params = $this->app->parameter->create($this->application->getParams()->get('global.comments.')); } public function save() { // check for request forgeries $this->app->session->checkToken() or jexit('Invalid Token'); // set currently active author $this->author = $this->app->comment->activeAuthor(); // init vars $redirect = $this->app->request->getString('redirect'); $login = $this->app->request->getCmd(CommentHelper::COOKIE_PREFIX.'login', '', 'cookie'); if ($this->author->getUserType() == $login) { if ($this->params->get('enable_comments', false)) { // init vars $content = $this->app->request->getVar('content', null, '', 'string', JREQUEST_ALLOWRAW); $item_id = $this->app->request->getInt('item_id', 0); $parent_id = $this->app->request->getInt('parent_id', 0); // filter content $content = $this->app->comment->filterContentInput($content); // set content in session $this->app->session->set('com_zoo.comment.content', $content); // set author name, email and url, if author is guest if ($this->author->isGuest()) { $this->author->name = $this->app->request->getString('author'); $this->author->email = $this->app->request->getString('email'); $this->author->url = $this->app->request->getString('url'); // save cookies $this->app->comment->saveCookies($this->author->name, $this->author->email, $this->author->url); } try { // Check captcha if ($plugin = $this->params->get('captcha', false) and (!$this->params->get('captcha_guest_only', 0) or !$this->app->user->get()->id)){ $captcha = JCaptcha::getInstance($plugin); if (!$captcha->checkAnswer($this->app->request->getString('captcha', ''))) { $error = $captcha->getError(); if (!($error instanceof Exception)) { $error = new JException($error); } throw new CommentControllerException(JText::_('ZOO_CHECK_CAPTCHA') . ' - ' . $error ); } } // get comment table $table = $this->app->table->comment; // get parent $parent = $table->get($parent_id); $parent_id = ($parent && $parent->item_id == $item_id) ? $parent->id : 0; // create comment $comment = $this->app->object->create('Comment'); $comment->parent_id = $parent_id; $comment->item_id = $item_id; $comment->ip = $this->app->useragent->ip(); $comment->created = $this->app->date->create()->toSQL(); $comment->content = $content; $comment->state = Comment::STATE_UNAPPROVED; // auto approve comment $approved = $this->params->get('approved', 0); if ($this->author->isJoomlaAdmin()) { $comment->state = Comment::STATE_APPROVED; } else if ($approved == 1) { $comment->state = Comment::STATE_APPROVED; } else if ($approved == 2 && $table->getApprovedCommentCount($this->author)) { $comment->state = Comment::STATE_APPROVED; } // bind Author $comment->bindAuthor($this->author); // validate comment, if not an administrator if (!$this->author->isJoomlaAdmin()) { $this->_validate($comment); } // save comment $table->save($comment); // remove content from session, if comment was saved $this->app->session->set('com_zoo.comment.content', ''); } catch (CommentControllerException $e) { // raise warning on exception $this->app->error->raiseWarning(0, (string) $e); } catch (AppException $e) { // raise warning on exception $this->app->error->raiseWarning(0, JText::_('ERROR_SAVING_COMMENT')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, (string) $e); } } // add anchor to redirect, if comment was saved if ($comment->id) { $redirect .= '#comment-'.$comment->id; } } else { // raise warning on comments not enabled $this->app->error->raiseWarning(0, JText::_('Comments are not enabled.')); } } else { // raise warning on exception $this->app->error->raiseWarning(0, JText::_('ERROR_SAVING_COMMENT')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, JText::_('User types didn\'t match.')); } } $this->setRedirect($redirect); } public function unsubscribe() { // init vars $item_id = $this->app->request->getInt('item_id'); $email = $this->app->request->getString('email'); $hash = $this->app->request->getCmd('hash'); $msg = ''; $redirect = 'index.php'; try { if ($hash != $this->app->comment->getCookieHash($email, $item_id, '')) { throw new CommentControllerException('Hashes did not match.'); } // subscribe author to item if (!($item = $this->app->table->item->get($item_id))) { throw new CommentControllerException('Item not found.'); } $this->app->table->item->save($item->unsubscribe($email)); $redirect = $this->app->route->item($item, false); $msg = JText::_('SUCCESSFULLY_UNSUBSCRIBED'); } catch (CommentControllerException $e) { // raise warning on exception $this->app->error->raiseWarning(0, (string) $e); } catch (AppException $e) { // raise warning on exception $this->app->error->raiseWarning(0, JText::_('ERROR_UNSUBSCRIBING')); // add exception details, for super administrators only if ($this->user->superadmin) { $this->app->error->raiseWarning(0, (string) $e); } } $this->setRedirect(JRoute::_($redirect), $msg); } protected function _validate($comment) { // get params $require_author = $this->params->get('require_name_and_mail', 0); $registered = $this->params->get('registered_users_only', 0); $time_between_user_posts = $this->params->get('time_between_user_posts', 120); $blacklist = $this->params->get('blacklist', ''); // check if related item exists if ($this->app->table->item->get($comment->item_id) === null) { throw new CommentControllerException('Related item does not exists.'); } // only registered users can comment if ($registered && $this->author->isGuest()) { throw new CommentControllerException('LOGIN_TO_LEAVE_OMMENT'); } // validate required name/email if ($this->author->isGuest() && $require_author && (empty($comment->author) || empty($comment->email))) { throw new CommentControllerException('Please enter the required fields author and email.'); } // validate email format try { $this->app->validator->create('email')->addOption('required', false)->clean($comment->email); } catch (AppValidatorException $e) { throw new CommentControllerException('Please enter a valid email address.'); } // validate url format try { $this->app->validator->create('url')->addOption('required', false)->clean($comment->url); } catch (AppValidatorException $e) { throw new CommentControllerException('Please enter a valid website link.'); } // check if content is empty if (empty($comment->content)) { throw new CommentControllerException('Please enter a comment.'); } // check quick multiple posts if ($last = $this->app->table->comment->getLastComment($comment->ip, $this->author)) { if ($this->app->date->create($comment->created)->toUnix() < $this->app->date->create($last->created)->toUnix() + $time_between_user_posts) { throw new CommentControllerException('You are posting comments too quickly. Slow down a bit.'); } } // check against spam blacklist if ($this->app->comment->matchWords($comment, $blacklist) && $comment->state != Comment::STATE_SPAM) { $comment->state = Comment::STATE_SPAM; } // check comment for spam (akismet) if ($this->params->get('akismet_enable', 0) && $comment->state != Comment::STATE_SPAM) { try { $this->app->comment->akismet($comment, $this->params->get('akismet_api_key')); } catch (Exception $e) { // re-throw exception, for super administrators only if ($this->user->superadmin) throw new AppException($e->getMessage()); } } // check comment for spam (mollom) if ($this->params->get('mollom_enable', 0) && $comment->state != Comment::STATE_SPAM) { try { $this->app->comment->mollom($comment, $this->params->get('mollom_public_key'), $this->params->get('mollom_private_key')); } catch (Exception $e) { // re-throw exception, for super administrators only if ($this->user->superadmin) throw new AppException($e->getMessage()); } } } public function facebookConnect() { // init vars $item_id = $this->app->request->getInt('item_id', 0); $item = $this->app->table->item->get($item_id); // get facebook client $connection = $this->app->facebook->client(); if ($connection && empty($connection->access_token)) { $redirect = JURI::root().'index.php?option='.$this->option.'&controller='.$this->controller.'&task=facebookauthenticate&item_id='.$item_id; $redirect = $connection->getAuthenticateURL($redirect); } else { // already connected $redirect = $this->app->route->item($item); } $this->setRedirect($redirect); } public function facebookAuthenticate() { // init vars $item_id = $this->app->request->getInt('item_id', 0); $item = $this->app->table->item->get($item_id); // get facebook client $connection = $this->app->facebook->client(); if ($connection) { $code = $this->app->request->getString('code', ''); $redirect = JURI::root() .'index.php?option='.$this->option.'&controller='.$this->controller.'&task=facebookauthenticate&item_id='.$item_id; $url = $connection->getAccessTokenURL($code, $redirect); $result = $this->app->http->get($url, array('ssl_verifypeer' => false)); $token = str_replace('access_token=', '', $result['body']); $_SESSION['facebook_access_token'] = $token; } $this->setRedirect($this->app->route->item($item)); } public function facebookLogout() { $this->app->facebook->logout(); $this->setRedirect($this->app->request->getString('HTTP_REFERER', '', 'server')); } public function twitterConnect() { // get twitter client $connection = $this->app->twitter->client(); // redirect to the referer after authorize/login procedure $referer = $this->app->request->getString('HTTP_REFERER', '', 'server'); // retrieve request token only if token is not supplied already if ($connection && empty($connection->token)) { $redirect = JURI::root() .'index.php?option='.$this->option.'&app_id='.$this->application->id.'&controller='.$this->controller.'&task=twitterauthenticate&referer='.urlencode($referer); // get temporary credentials $request_token = $connection->getRequestToken($redirect); // save temporary credentials to session $_SESSION['twitter_oauth_token'] = $token = $request_token['oauth_token']; $_SESSION['twitter_oauth_token_secret'] = $request_token['oauth_token_secret']; // if last connection failed don't display authorization link switch ($connection->http_code) { case 200: // build authorize URL and redirect user to Twitter $redirect = $connection->getAuthorizeURL($token); break; default: // show notification if something went wrong. $this->app->error->raiseWarning(0, JText::_('ERROR_CONNECT_TWITTER')); $redirect = $referer; } } else { // already connected $redirect = $referer; } $this->setRedirect($redirect); } public function twitterAuthenticate() { // get twitter client $connection = $this->app->twitter->client(); if ($connection) { // retrieve access token $token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']); // replace request token with access token in session. if ($token_credentials) { $_SESSION['twitter_oauth_token'] = $token_credentials['oauth_token']; $_SESSION['twitter_oauth_token_secret'] = $token_credentials['oauth_token_secret']; } else { // show notification if something went wrong. $this->app->error->raiseWarning(0, JText::_('ERROR_CONNECT_TWITTER')); } } $this->setRedirect($this->app->request->getString('referer')); } public function twitterLogout() { $this->app->twitter->logout(); $this->setRedirect($this->app->request->getString('HTTP_REFERER', '', 'server')); } } /* Class: CommentControllerException */ class CommentControllerException extends AppException { /** * Converts the exception to a human readable string * * @return string The error message * * @since 1.0.0 */ public function __toString() { return JText::_($this->getMessage()); } }controllers/index.html000066600000000036150773114110011112 0ustar00controllers/item.php000066600000014150150773114110010566 0ustar00table = $this->app->table->item; // get application $this->application = $this->app->zoo->getApplication(); // set user $this->user = $this->app->user->get(); } public function element() { // include template css $template = $this->app->database->queryResult('SELECT template FROM #__template_styles WHERE client_id = 1 AND home = 1'); $this->app->document->addStylesheet("root:administrator/templates/$template/css/template.css"); jimport('joomla.html.pagination'); // get database $this->db = $this->app->database; // get Joomla application $this->joomla = $this->app->system->application; // get request vars $this->filter_item = $this->app->request->getInt('item_filter', 0); $this->type_filter = $this->app->request->get('type_filter', 'array', array()); $state_prefix = $this->option.'_'.$this->application->id.'.'.($this->getTask() == 'element' ? 'element' : 'item').'.'; $filter_order = $this->joomla->getUserStateFromRequest($state_prefix.'filter_order', 'filter_order', 'a.created', 'cmd'); $filter_order_Dir = $this->joomla->getUserStateFromRequest($state_prefix.'filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); $filter_category_id = $this->joomla->getUserStateFromRequest($state_prefix.'filter_category_id', 'filter_category_id', '-1', 'string'); $filter_type = $this->joomla->getUserStateFromRequest($state_prefix.'filter_type', 'filter_type', '', 'string'); $filter_author_id = $this->joomla->getUserStateFromRequest($state_prefix.'filter_author_id', 'filter_author_id', 0, 'int'); $search = $this->joomla->getUserStateFromRequest($state_prefix.'search', 'search', '', 'string'); $search = $this->app->string->strtolower($search); $page = $this->app->request->getInt('page', 1); $limit = ItemController::PAGINATION_LIMIT; // is filtered ? $this->is_filtered = $filter_category_id <> '-1' || !empty($filter_type) || !empty($filter_author_id) || !empty($search); $this->users = $this->table->getUsers($this->application->id); $this->groups = $this->app->zoo->getGroups(); // select $select = 'a.*'; // get from $from = $this->table->name.' AS a'; // get data from the table $where = array(); // application filter $where[] = 'a.application_id = ' . (int) $this->application->id; // category filter if ($filter_category_id === '') { $from .= ' LEFT JOIN '.ZOO_TABLE_CATEGORY_ITEM.' AS ci ON a.id = ci.item_id'; $where[] = 'ci.item_id IS NULL'; } else if ($filter_category_id > -1) { $from .= ' LEFT JOIN '.ZOO_TABLE_CATEGORY_ITEM.' AS ci ON a.id = ci.item_id'; $where[] = 'ci.category_id = ' . (int) $filter_category_id; } // type filter if (!empty($this->type_filter)) { $where[] = 'a.type IN ("' . implode('", "', $this->type_filter) . '")'; } else if (!empty($filter_type)) { $where[] = 'a.type = "' . (string) $filter_type . '"'; } // item filter if ($this->filter_item > 0) { $where[] = 'a.id != ' . (int) $this->filter_item; } // author filter if ($filter_author_id > 0) { $where[] = 'a.created_by = ' . (int) $filter_author_id; } if ($search) { $from .= ' LEFT JOIN '.ZOO_TABLE_TAG.' AS t ON a.id = t.item_id'; $where[] = '(LOWER(a.name) LIKE '.$this->db->Quote('%'.$this->db->escape($search, true).'%', false) . ' OR LOWER(t.name) LIKE '.$this->db->Quote('%'.$this->db->escape($search, true).'%', false) . ' OR LOWER(a.alias) LIKE '.$this->db->Quote('%'.$this->db->escape($search, true).'%', false).')'; } // access filter $where[] = 'a.'.$this->app->user->getDBAccessString($this->user); // state filter $where[] = 'a.state = 1'; $options = array( 'select' => $select, 'from' => $from, 'conditions' => array(implode(' AND ', $where)), 'order' => $filter_order.' '.$filter_order_Dir, 'group' => 'a.id'); $count = $this->table->count($options); // in case limit has been changed, adjust limitstart accordingly $limitstart = ($page - 1) * $limit; $this->items = $this->table->all($limit > 0 ? array_merge($options, array('offset' => $limitstart, 'limit' => $limit)) : $options); $this->items = array_merge($this->items); $this->pagination = $this->app->pagination->create($count, $limitstart, $limit, 'page', 'app'); // category select $options = array(); $options[] = $this->app->html->_('select.option', '-1', '- ' . JText::_('Select Category') . ' -'); $options[] = $this->app->html->_('select.option', '', '- ' . JText::_('uncategorized') . ' -'); $options[] = $this->app->html->_('select.option', '0', '- '.JText::_('Frontpage')); $this->lists['select_category'] = $this->app->html->_('zoo.categorylist', $this->application, $options, 'filter_category_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_category_id); // type select $options = array($this->app->html->_('select.option', '0', '- '.JText::_('Select Type').' -')); $this->lists['select_type'] = $this->app->html->_('zoo.typelist', $this->application, $options, 'filter_type', 'class="inputbox auto-submit"', 'value', 'text', $filter_type, false, false, $this->type_filter); // author select $options = array($this->app->html->_('select.option', '0', '- '.JText::_('Select Author').' -')); $this->lists['select_author'] = $this->app->html->_('zoo.itemauthorlist', $options, 'filter_author_id', 'class="inputbox auto-submit"', 'value', 'text', $filter_author_id); // table ordering and search filter $this->lists['order_Dir'] = $filter_order_Dir; $this->lists['order'] = $filter_order; $this->lists['search'] = $search; $this->getView()->setLayout('element')->display(); } }partials/_submission.php000066600000005176150773114110011443 0ustar00app->document->addScript('libraries:jquery/jquery-ui.custom.min.js'); $this->app->document->addStylesheet('libraries:jquery/jquery-ui.custom.css'); $this->app->document->addScript('libraries:jquery/plugins/timepicker/timepicker.js'); $this->app->document->addStylesheet('libraries:jquery/plugins/timepicker/timepicker.css'); $this->app->document->addStylesheet('assets:css/submission.css'); $this->app->document->addScript('assets:js/submission.js'); $this->app->document->addScript('assets:js/placeholder.js'); $this->app->document->addScript('assets:js/item.js'); if ($this->submission->showTooltip()) { $this->app->html->_('behavior.tooltip'); } ?> errors): ?> errors) > 1 ? JText::_('Oops. There were errors in your submission.') : JText::_('Oops. There was an error in your submission.'); ?>

    renderer->render($this->layout_path, array('item' => $this->item, 'submission' => $this->submission)); // Captcha support if ($this->captcha) { $this->app->html->_('behavior.framework'); echo $this->captcha->display('captcha', 'captcha', 'captcha'); } ?>

    cancelUrl) : ?>
    app->html->_('form.token'); ?>
    partials/_respond.php000066600000010675150773114110010722 0ustar00get('registered_users_only'); $this->app->document->addScript('assets:js/placeholder.js'); ?>

    name.' ('.JText::_('Joomla').')'; ?>

    name.' ('.JText::_('Facebook').')'; ?> -

    name.' ('.JText::_('Twitter').')'; ?> -

    isGuest()) : ?>

    get('facebook_enable') || $params->get('twitter_enable')) echo JText::_('Optional login below.'); ?>

    get('facebook_enable') || $params->get('twitter_enable')) : ?>

    get('facebook_enable')) : ?> get('twitter_enable')) : ?>

    get('require_name_and_mail');?>
    " value="name; ?>"/>
    isGuest())) : ?>
    app->html->_('behavior.framework'); ?>
    display('captcha', 'captcha', 'captcha'); ?>
    app->html->_('form.token'); ?>
    partials/_comments.php000066600000003065150773114110011070 0ustar00app->document->addScript('libraries:jquery/plugins/cookie/jquery-cookie.js'); $this->app->document->addScript('assets:js/comment.js'); $this->app->document->addStylesheet('assets:css/comments.css'); // css classes $css[] = 'level1'; $css[] = $params->get('max_depth', 5) > 1 ? 'nested' : null; $css[] = $params->get('registered_users_only') && $active_author->isGuest() ? 'no-response' : null; ?>

      "> getChildren() as $comment) { echo $this->partial('comment', array('level' => 1, 'comment' => $comment, 'author' => $comment->getAuthor(), 'params' => $params)); } ?>
    isCommentsEnabled()) : echo $this->partial('respond', compact('active_author', 'params', 'item', 'captcha')); endif; ?>
    partials/index.html000066600000000036150773114110010363 0ustar00partials/_comment.php000066600000003746150773114110010713 0ustar00name = $author->name ? $author->name : JText::_('Anonymous'); ?>
  • get('avatar', 0)) : ?>
    getAvatar(50); ?>
    url) : ?>

    name; ?>

    name; ?>

    app->html->_('date', $comment->created, $this->app->date->format(JText::_('DATE_FORMAT_COMMENTS')), $this->app->date->getOffset()); ?> |
    app->comment->filterContentOutput($comment->content); ?>
    getItem()->isCommentsEnabled()) : ?>
    state != Comment::STATE_APPROVED) : ?>
    hasChildren()) : ?>
      getChildren() as $comment) { echo $this->partial('comment', array('level' => $level, 'comment' => $comment, 'author' => $comment->getAuthor(), 'params' => $params)); } ?>
  • partials/_mysubmissions.php000066600000007147150773114110012174 0ustar00app->document->addStylesheet('assets:css/submission.css'); $this->app->document->addScript('assets:js/submission.js'); $mysubmissions_link = $this->app->route->mysubmissions($this->submission); ?>
    show_add): ?>
    lists['select_type'])) : ?>
    lists['select_type']; ?>
    items)) : ?>
      items as $id => $item) : ?>
    • submission->isInTrustedMode()) : ?> app->route->submission($this->submission, $item->type, null, $id, 'mysubmissions'); ?>

      name; ?> (getType()->name; ?>)

      params = $item->getParams('site'); ?> renderer->pathExists('item/'.$item->type)) ? $item->type : 'item'; ?>
    lists['search'])) : ?>

    filter_type); ?>

    sef_ext/index.html000066600000000036150773114110010201 0ustar00sef_ext/com_zoo.php000066600000015330150773114110010365 0ustar00getQuery(true); // if task is empty get task from view parameter $task = !empty($task) ? $task : (isset($query['view']) ? $query['view'] : null); $controller = isset($query['controller']) ? $query['controller'] : null; // ignore ajax requests if (in_array($task, array('remove', 'callelement', 'element')) || in_array($controller, array('comment', 'item'))) { $dosef = false; } switch ($task) { case 'alphaindex': $title[] = $task; $title[] = $zoo->alias->application->translateIDToAlias((int) $query['app_id']); $title[] = $query['alpha_char']; shRemoveFromGETVarsList('app_id'); shRemoveFromGETVarsList('alpha_char'); // pagination if (isset($query['page'])) { $title[] = $query['page']; shRemoveFromGETVarsList('page'); } break; case 'category': // retrieve item id from menu item if (!isset($query['category_id'])) { $query['category_id'] = $zoo->object->create('JSite')->getMenu()->getParams($Itemid)->get('category'); } $title[] = $task; $title[] = $zoo->alias->category->translateIDToAlias((int) $query['category_id']); // pagination if (isset($query['page'])) { $title[] = $query['page']; shRemoveFromGETVarsList('page'); } shRemoveFromGETVarsList('category_id'); break; case 'feed': $title[] = $task; $title[] = $query['type']; $title[] = $zoo->alias->application->translateIDToAlias((int) $query['app_id']); $title[] = $zoo->alias->category->translateIDToAlias((int) $query['category_id']); shRemoveFromGETVarsList('type'); shRemoveFromGETVarsList('app_id'); shRemoveFromGETVarsList('category_id'); break; case 'frontpage': // retrieve app id from menu item if (!isset($query['app_id'])) { $query['app_id'] = $zoo->object->create('JSite')->getMenu()->getParams($Itemid)->get('application'); } $title[] = $task; $title[] = $zoo->alias->application->translateIDToAlias($query['app_id']); // pagination if (isset($query['page'])) { $title[] = $query['page']; shRemoveFromGETVarsList('page'); } break; case 'item': // retrieve item id from menu item if (!isset($query['item_id'])) { $query['item_id'] = $zoo->object->create('JSite')->getMenu()->getParams($Itemid)->get('item_id'); } $title[] = $task; $title[] = $zoo->alias->item->translateIDToAlias((int) $query['item_id']); shRemoveFromGETVarsList('item_id'); break; case 'submission': // get menu $menu_params = $zoo->object->create('JSite')->getMenu()->getParams($Itemid); // retrieve item id from menu item if (!isset($query['submission_id'])) { $query['submission_id'] = $menu_params->get('submission'); $query['type_id'] = $menu_params->get('type'); $query['item_id'] = $menu_params->get('item_id'); $query['submission_hash'] = ''; } if ($query['layout'] == 'submission') { $title[] = $task; $title[] = $query['layout']; $title[] = $zoo->alias->submission->translateIDToAlias((int) $query['submission_id']); $title[] = $query['type_id']; $title[] = $query['submission_hash']; $title[] = $zoo->alias->item->translateIDToAlias((int) @$query['item_id']); $title = array_filter($title); shRemoveFromGETVarsList('layout'); shRemoveFromGETVarsList('submission_id'); shRemoveFromGETVarsList('type_id'); shRemoveFromGETVarsList('submission_hash'); shRemoveFromGETVarsList('item_id'); } else if ($query['layout'] == 'mysubmissions') { $title[] = $task; $title[] = $query['layout']; $title[] = $zoo->alias->submission->translateIDToAlias((int) $query['submission_id']); shRemoveFromGETVarsList('layout'); shRemoveFromGETVarsList('submission_id'); } break; case 'tag': $title[] = $task; $title[] = $zoo->alias->application->translateIDToAlias((int) $query['app_id']); $title[] = $query['tag']; shRemoveFromGETVarsList('app_id'); shRemoveFromGETVarsList('tag'); // pagination if (isset($query['page'])) { $title[] = $query['page']; shRemoveFromGETVarsList('page'); } break; default: // trigger sh404sef event $zoo->event->dispatcher->notify($zoo->event->create(null, 'application:sh404sef', array('title' => &$title, 'query' => &$query, 'dosef' => &$dosef))); } shRemoveFromGETVarsList('task'); shRemoveFromGETVarsList('view'); shRemoveFromGETVarsList('layout'); // ZOO ZOO ZOO ZOO ZOO ZOO ZOO ZOO // ------------------ standard plugin finalize function - don't change --------------------------- if ($dosef) { $string = shFinalizePlugin( $string, $title, $shAppendString, $shItemidString, (isset($limit) ? @$limit : null), (isset($limitstart) ? @$limitstart : null), (isset($shLangName) ? @$shLangName : null)); } // ------------------ standard plugin finalize function - don't change ---------------------------