Ejemplo n.º 1
0
 public function __construct($default = array())
 {
     parent::__construct($default);
     // get application group
     $this->group = YRequest::getString('group');
     // if group exists
     if ($this->group) {
         // add group to base url
         $this->baseurl .= '&group=' . $this->group;
         // create application object
         $this->application = new Application();
         $this->application->setGroup($this->group);
     }
 }
Ejemplo n.º 2
0
 public function update()
 {
     // init vars
     $old = YRequest::getString('old');
     $new = YRequest::getString('new');
     $msg = null;
     try {
         $app = Zoo::getApplication();
         // update tag
         if (!empty($new) && $old != $new) {
             YTable::getInstance('tag')->update($app->id, $old, $new);
             // set redirect message
             $msg = JText::_('Tag Updated Successfully');
         }
     } catch (YException $e) {
         // raise notice on exception
         JError::raiseWarning(0, JText::_('Error Updating Tag') . ' (' . $e . ')');
     }
     $this->setRedirect($this->baseurl, $msg);
 }
Ejemplo n.º 3
0
 public function saveSubmission()
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     // init vars
     $type = YRequest::getString('type');
     $template = YRequest::getString('template');
     $layout = YRequest::getString('layout');
     $positions = YRequest::getVar('positions', array(), 'post', 'array');
     unset($positions['unassigned']);
     // for template, module
     if ($template) {
         $path = $this->application->getPath() . '/templates/' . $template;
     }
     // get renderer
     $renderer = new ItemRenderer();
     $renderer->addPath($path);
     // clean config
     $config = $renderer->getConfig('item');
     foreach ($config->toArray() as $key => $value) {
         $parts = explode('.', $key);
         if ($parts[0] == $this->group && !$this->application->getType($parts[1])) {
             $config->remove($key);
         }
     }
     // save config
     $config->set($this->group . '.' . $type . '.' . $layout, $positions);
     $renderer->saveConfig($config, $path . '/renderer/item/positions.config');
     switch ($this->getTask()) {
         case 'applysubmission':
             $link = $this->baseurl . '&task=assignsubmission&type=' . $type . '&layout=' . $layout;
             $link .= $template ? '&template=' . $template : null;
             break;
         default:
             $link = $this->baseurl . '&task=types';
             break;
     }
     $this->setRedirect($link, JText::_('Submitable Elements Assigned'));
 }
Ejemplo n.º 4
0
 public function callElement()
 {
     // get request vars
     $element_identifier = YRequest::getString('elm_id', '');
     $item_id = YRequest::getInt('item_id', 0);
     $type = YRequest::getString('type', '');
     $this->method = YRequest::getCmd('method', '');
     $this->args = YRequest::getVar('args', array(), 'default', 'array');
     JArrayHelper::toString($this->args);
     // load element
     if ($item_id) {
         $item = YTable::getInstance('item')->get($item_id);
     } elseif (!empty($type)) {
         $item = new Item();
         $item->application_id = $this->application->id;
         $item->type = $type;
     }
     // execute callback method
     if ($element = $item->getElement($element_identifier)) {
         echo $element->callback($this->method, $this->args);
     }
 }
Ejemplo n.º 5
0
 public function tag()
 {
     // get request vars
     $page = YRequest::getInt('page', 1);
     $this->tag = YRequest::getString('tag', '');
     // get params
     $params = $this->application->getParams('site');
     $items_per_page = $params->get('config.items_per_page', 15);
     $this->item_order = $this->_getItemOrder($params->get('config.item_order'));
     // get categories and items
     $this->categories = $this->application->getCategoryTree(true);
     $this->items = YTable::getInstance('item')->getByTag($this->application->id, $this->tag, true, null, $this->item_order);
     // get item pagination
     $this->pagination = new YPagination('page', count($this->items), $page, $items_per_page);
     $this->pagination->setShowAll($items_per_page == 0);
     $this->pagination_link = RouteHelper::getTagRoute($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();
     }
     // create pathway
     $link = JRoute::_(RouteHelper::getTagRoute($this->application->id, $this->tag));
     $this->pathway->addItem(JText::_('Tags') . ': ' . $this->tag, $link);
     // get template and params
     if (!($this->template = $this->application->getTemplate())) {
         JError::raiseError(500, JText::_('No template selected'));
         return;
     }
     $this->params = $params;
     // set renderer
     $this->renderer = new ItemRenderer();
     $this->renderer->addPath(array($this->template->getPath(), ZOO_SITE_PATH));
     // display view
     $this->getView('tag')->addTemplatePath($this->template->getPath())->setLayout('tag')->display();
 }
Ejemplo n.º 6
0
" accesskey="s"/>
				<a href="#" class="cancel"><?php 
    echo JText::_('Cancel');
    ?>
</a>
				<span class="submit-message">
					<?php 
    echo JText::_('Submitting comment...');
    ?>
				</span>		
			</div>
			
			<input type="hidden" name="item_id" value="<?php 
    echo $this->item->id;
    ?>
"/>
			<input type="hidden" name="parent_id" value="0"/>
			<input type="hidden" name="redirect" value="<?php 
    echo str_replace('&', '&amp;', YRequest::getString('REQUEST_URI', '', 'server'));
    ?>
"/>
			<?php 
    echo JHTML::_('form.token');
    ?>
			
		<?php 
}
?>
		
	</form>
</div>
Ejemplo n.º 7
0
 public static function readCookies()
 {
     // get cookies
     foreach (array('hash', 'author', 'email', 'url') as $key) {
         $data[$key] = YRequest::getString(self::COOKIE_PREFIX . $key, '', 'cookie');
     }
     // verify hash
     if (self::getCookieHash($data['author'], $data['email'], $data['url']) == $data['hash']) {
         return $data;
     }
     return array('hash' => null, 'author' => null, 'email' => null, 'url' => null);
 }
Ejemplo n.º 8
0
// load config
require_once dirname(__FILE__) . '/config.php';
// add css, js
JHTML::script('jquery-ui-1.8.6.custom.min.js', ZOO_ADMIN_URI . 'libraries/jquery/');
JHTML::stylesheet('jquery-ui-1.8.6.custom.css', ZOO_ADMIN_URI . 'libraries/jquery/');
JHTML::script('accordionmenu.js', ZOO_ADMIN_URI . 'assets/js/');
JHTML::script('placeholder.js', ZOO_ADMIN_URI . 'assets/js/');
JHTML::script('jquery.pnotify.js', ZOO_ADMIN_URI . 'libraries/jquery/plugins/notifier/');
JHTML::stylesheet('jquery.pnotify.default.css', ZOO_ADMIN_URI . 'libraries/jquery/plugins/notifier/');
JHTML::script('default.js', ZOO_ADMIN_URI . 'assets/js/');
JHTML::stylesheet('ui.css', ZOO_ADMIN_URI . 'assets/css/');
JHTMLBehavior::modal();
// init vars
$controller = YRequest::getWord('controller');
$task = YRequest::getWord('task');
$group = YRequest::getString('group');
// change application
if ($id = YRequest::getInt('changeapp')) {
    JFactory::getApplication()->setUserState('com_zooapplication', $id);
}
// load application
$application = Zoo::getApplication();
// set default controller
if (!$controller) {
    $controller = $application ? 'item' : 'new';
    YRequest::setVar('controller', $controller);
}
// set toolbar button include path
$toolbar = JToolBar::getInstance('toolbar');
$toolbar->addButtonPath(ZOO_ADMIN_PATH . '/joomla/button');
// build menu
Ejemplo n.º 9
0
 protected function _init()
 {
     //init vars
     $type_id = JRequest::getString('type_id');
     $hash = JRequest::getString('submission_hash');
     $this->redirect = YRequest::getString('redirect');
     // check config
     $this->_checkConfig();
     // get submission info from request
     if ($type_id) {
         if ($hash != SubmissionHelper::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 : SubmissionHelper::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 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) {
             if ($element_obj = $this->type->getElement($element->element)) {
                 if (!$this->submission->isInTrustedMode()) {
                     $metadata = $element_obj->getMetaData();
                     if ($metadata['trusted'] == 'true') {
                         continue;
                     }
                 }
                 $this->elements_config[$element->element] = $element;
             }
         }
     }
     // get item table
     $table = YTable::getInstance('item');
     // get item
     if (!$this->item_id || !($this->item = $table->get($this->item_id))) {
         $this->item = new Item();
         $this->item->application_id = $this->application->id;
         $this->item->type = $this->type->id;
         $now = JFactory::getDate();
         $config = JFactory::getConfig();
         $offset = $config->getValue('config.offset');
         $now->setOffset($offset);
         $this->item->publish_up = $now->toFormat(SubmissionController::EDIT_DATE_FORMAT);
         $this->item->publish_down = YDatabase::getInstance()->getNullDate();
     }
 }
Ejemplo n.º 10
0
 public function twitterLogout()
 {
     CommentHelper::twitterLogout();
     $this->setRedirect(YRequest::getString('HTTP_REFERER', '', 'server'));
 }