public function testGetDiffCategories() { $categories = self::$data; $newCategories = self::$data; $newCategories[0]['name'] = '3rd test category'; $expected = [$newCategories[0]]; $actual = CategoryHelper::getDiffCategories($categories, $newCategories); $this->assertEquals($expected, $actual); }
public function delete($object) { // get database $db = $this->getDBO(); // update childrens parent category $query = "UPDATE " . $this->getTableName() . " SET parent=" . $object->parent . " WHERE parent=" . $object->id; $db->query($query); // delete category to item relations CategoryHelper::deleteCategoryItemRelations($object->id); return parent::delete($object); }
public function getPreview($wikitext) { // TODO: use wgParser here because some parser hooks initialize themselves on wgParser (should on provided parser instance) global $wgParser, $wgUser, $wgRequest; wfProfileIn(__METHOD__); $wg = $this->app->wg; $parserOptions = new ParserOptions($wgUser); $originalWikitext = $wikitext; if (!empty($wg->EnableCategorySelectExt)) { // if CategorySelect is enabled, add categories to wikitext $categories = $wg->Request->getVal('categories', ''); $wikitext .= CategoryHelper::changeFormat($categories, 'json', 'wikitext'); } // call preSaveTransform so signatures, {{subst:foo}}, etc. will work $wikitext = $wgParser->preSaveTransform($wikitext, $this->mTitle, $this->app->getGlobal('wgUser'), $parserOptions); // parse wikitext using MW parser $parserOutput = $wgParser->parse($wikitext, $this->mTitle, $parserOptions); /** * Allow extensions to modify the ParserOutput */ wfRunHooks('ArticlePreviewAfterParse', [$parserOutput, $this->mTitle]); $html = $parserOutput->getText(); $html = EditPageService::wrapBodyText($this->mTitle, $wgRequest, $html); // we should also render categories and interlanguage links $catbox = $this->renderCategoryBoxFromParserOutput($parserOutput); $interlanglinks = $this->renderInterlangBoxFromParserOutput($parserOutput); /** * bugid: 47995 -- Treat JavaScript and CSS as raw text wrapped in <pre> tags * We still rely on the parser for other stuff */ if ($this->mTitle->isCssOrJsPage()) { $html = '<pre>' . htmlspecialchars($originalWikitext) . '</pre>'; } wfProfileOut(__METHOD__); return array($html, $catbox, $interlanglinks); }
public function getRelatedCategoryIds($published = false) { if ($this->_related_category_ids === null) { $this->_related_category_ids = CategoryHelper::getItemsRelatedCategoryIds($this->id, $published); } return $this->_related_category_ids; }
/** * Set global variables for javascript */ public static function onMakeGlobalVariablesScript(array &$vars) { $wg = F::app()->wg; $vars['wgCategorySelect'] = array('defaultNamespace' => $wg->ContLang->getNsText(NS_CATEGORY), 'defaultNamespaces' => CategoryHelper::getDefaultNamespaces(), 'defaultSeparator' => trim(wfMessage('colon-separator')->escaped()), 'defaultSortKey' => $wg->Parser->getDefaultSort() ?: $wg->Title->getText()); return true; }
/** * Save categories sent via AJAX into article */ public function save() { wfProfileIn(__METHOD__); $articleId = $this->request->getVal('articleId', 0); $categories = $this->request->getVal('categories', array()); $response = array(); $title = Title::newFromID($articleId); if (wfReadOnly()) { $response['error'] = wfMessage('categoryselect-error-db-locked')->text(); } else { if (is_null($title)) { $response['error'] = wfMessage('categoryselect-error-article-doesnt-exist', $articleId)->text(); } else { if (!$title->userCan('edit') || $this->wg->User->isBlocked()) { $response['error'] = wfMessage('categoryselect-error-user-rights')->text(); } else { if (!empty($categories) && is_array($categories)) { Wikia::setVar('EditFromViewMode', 'CategorySelect'); $article = new Article($title); $wikitext = $article->fetchContent(); // Pull in categories from templates inside of the article (BugId:100980) $options = new ParserOptions(); $preprocessedWikitext = ParserPool::preprocess($wikitext, $title, $options); $preprocessedData = CategoryHelper::extractCategoriesFromWikitext($preprocessedWikitext, true); // Compare the new categories with those already in the article to weed out duplicates $newCategories = CategoryHelper::getDiffCategories($preprocessedData['categories'], $categories); // Append the new categories to the end of the article wikitext $wikitext .= CategoryHelper::changeFormat($newCategories, 'array', 'wikitext'); // Update the array of categories for the front-end $categories = array_merge($preprocessedData['categories'], $newCategories); $dbw = wfGetDB(DB_MASTER); $dbw->begin(); $editPage = new EditPage($article); $editPage->edittime = $article->getTimestamp(); $editPage->recreate = true; $editPage->textbox1 = $wikitext; $editPage->summary = wfMessage('categoryselect-edit-summary')->inContentLanguage()->text(); $editPage->watchthis = $editPage->mTitle->userIsWatching(); $bot = $this->wg->User->isAllowed('bot'); $status = $editPage->internalAttemptSave($result, $bot)->value; $response['status'] = $status; switch ($status) { case EditPage::AS_SUCCESS_UPDATE: case EditPage::AS_SUCCESS_NEW_ARTICLE: $dbw->commit(); $title->invalidateCache(); Article::onArticleEdit($title); $response['html'] = $this->app->renderView('CategorySelectController', 'categories', array('categories' => $categories)); wfRunHooks('CategorySelectSave', array($title, $newCategories)); break; case EditPage::AS_SPAM_ERROR: $dbw->rollback(); $response['error'] = wfMessage('spamprotectiontext')->text() . '<p>( Case #8 )</p>'; break; default: $dbw->rollback(); $response['error'] = wfMessage('categoryselect-error-edit-abort')->text(); } } } } } $this->response->setData($response); wfProfileOut(__METHOD__); }
public static function importCSV($file, $type = '', $contains_headers = false, $field_separator = ',', $field_enclosure = '"', $element_assignment = array()) { // get application if ($application = Zoo::getApplication()) { if ($type_obj = $application->getType($type)) { $c = 0; $assignments = array(); foreach ($element_assignment as $column => $value) { if (!empty($value[$type])) { $name = $value[$type]; $assignments[$name][] = $column; } } if (!isset($assignments['_name'])) { throw new ImportHelperException('No item name was assigned.'); } if (($handle = fopen($file, "r")) !== FALSE) { $item_table = YTable::getInstance('item'); $category_table = YTable::getInstance('category'); $user_id = JFactory::getUser()->get('id'); $now = JFactory::getDate(); $row = 0; $app_categories = $application->getCategories(); $app_categories = array_map(create_function('$cat', 'return $cat->name;'), $app_categories); $elements = $type_obj->getElements(); while (($data = fgetcsv($handle, 0, $field_separator, $field_enclosure)) !== FALSE) { if (!($contains_headers && $row == 0)) { $item = new Item(); $item->application_id = $application->id; $item->type = $type; // store created by $item->created_by = $user_id; // set created $item->created = $now->toMySQL(); // store modified_by $item->modified_by = $user_id; // set modified $item->modified = $now->toMySQL(); // store element_data and item name $item_categories = array(); foreach ($assignments as $assignment => $columns) { $column = current($columns); switch ($assignment) { case '_name': $item->name = $data[$column]; break; case '_created_by_alias': $item->created_by_alias = $data[$column]; break; case '_created': if (!empty($data[$column])) { $item->created = $data[$column]; } break; default: if (substr($assignment, 0, 9) == '_category') { foreach ($columns as $column) { $item_categories[] = $data[$column]; } } else { if (isset($elements[$assignment])) { $elements[$assignment]->unsetData(); switch ($elements[$assignment]->getElementType()) { case 'text': case 'textarea': case 'link': case 'email': case 'date': $element_data = array(); foreach ($columns as $column) { if (!empty($data[$column])) { $element_data[$column] = array('value' => $data[$column]); } } $elements[$assignment]->bindData($element_data); break; case 'gallery': $data[$column] = trim($data[$column], '/\\'); $elements[$assignment]->bindData(array('value' => $data[$column])); break; case 'image': case 'download': $elements[$assignment]->bindData(array('file' => $data[$column])); break; case 'googlemaps': $elements[$assignment]->bindData(array('location' => $data[$column])); break; } } } break; } } $elements_string = '<?xml version="1.0" encoding="UTF-8"?><elements>'; foreach ($elements as $element) { $elements_string .= $element->toXML(); } $elements_string .= '</elements>'; $item->elements = $elements_string; $item->alias = YString::sluggify($item->name); if (empty($item->alias)) { $item->alias = '42'; } // set a valid category alias while (ItemHelper::checkAliasExists($item->alias)) { $item->alias .= '-2'; } if (!empty($item->name)) { try { $item_table->save($item); $item_id = $item->id; $item->unsetElementData(); // store categories foreach ($item_categories as $category_name) { if (!in_array($category_name, $app_categories)) { $category = new Category(); $category->application_id = $application->id; $category->name = $category_name; $category->parent = 0; $category->alias = YString::sluggify($category_name); // set a valid category alias while (CategoryHelper::checkAliasExists($category->alias)) { $category->alias .= '-2'; } try { $category_table->save($category); $related_categories[$category->id] = $category->name; $app_categories[$category->id] = $category->name; } catch (CategoryTableException $e) { } } else { $related_categories = array_filter($app_categories, create_function('$cat', 'return $cat=="' . $category_name . '";')); } // add category to item relations if (!empty($related_categories)) { CategoryHelper::saveCategoryItemRelations($item_id, array_keys($related_categories)); } } } catch (ItemTableException $e) { } } } $row++; } fclose($handle); return true; } else { throw new ImportHelperException('Could not open csv file.'); } } else { throw new ImportHelperException('Could not find type.'); } } throw new ImportHelperException('No application to import too.'); }
public function docopy() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $now = JFactory::getDate(); $post = YRequest::get('post'); $cid = YRequest::getArray('cid', array(), 'int'); if (count($cid) < 1) { JError::raiseError(500, JText::_('Select a item to copy')); } try { // get item table $item_table = YTable::getInstance('item'); $tag_table = YTable::getInstance('tag'); // get database $db = YDatabase::getInstance(); // copy items foreach ($cid as $id) { // get item $item = $item_table->get($id); $elements = $item->getElements(); $categories = $item->getRelatedCategoryIds(); // copy item $item->id = 0; // set id to 0, to force new item $item->name .= ' (' . JText::_('Copy') . ')'; // set copied name $item->alias = ItemHelper::getUniqueAlias($id, $item->alias . '-copy'); // set copied alias $item->state = 0; // unpublish item $item->created = $now->toMySQL(); $item->created_by = $this->user->get('id'); $item->modified = $now->toMySQL(); $item->modified_by = $this->user->get('id'); $item->hits = 0; // copy tags $item->setTags($tag_table->getItemTags($id)); // save copied item/element data $item_table->save($item); // save category relations CategoryHelper::saveCategoryItemRelations($item->id, $categories); } // set redirect message $msg = JText::_('Item Copied'); } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Copying Item') . ' (' . $e . ')'); $msg = null; } $this->setRedirect($this->baseurl, $msg); }
public function docopy() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $cid = YRequest::getArray('cid', array(), 'int'); if (count($cid) < 1) { JError::raiseError(500, JText::_('Select a category to copy')); } try { // get category table $table = YTable::getInstance('category'); // copy categories $parents = array(); foreach ($cid as $id) { // get category $category = $table->get($id); // copy category $category->id = 0; // set id to 0, to force new category $category->name .= ' (' . JText::_('Copy') . ')'; // set copied name $category->alias = CategoryHelper::getUniqueAlias($id, $category->alias . '-copy'); // set copied alias $category->published = 0; // unpublish category // track parent for ordering update $parents[] = $category->parent; // save copied category data $table->save($category); } // update category ordering $table->updateorder($this->application->id, $parents); // set redirect message $msg = JText::_('Category Copied'); } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Copying Category') . ' (' . $e . ')'); $msg = null; } $this->setRedirect($this->baseurl, $msg); }
$query['category_id'] = JSite::getMenu()->getParams($Itemid)->get('category'); } $title[] = $task; $title[] = CategoryHelper::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[] = ApplicationHelper::translateIDToAlias((int) $query['app_id']); $title[] = CategoryHelper::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'] = JSite::getMenu()->getParams($Itemid)->get('application'); } $title[] = $task; $title[] = ApplicationHelper::translateIDToAlias($query['app_id']); // pagination if (isset($query['page'])) { $title[] = $query['page']; shRemoveFromGETVarsList('page');
public function getCategoryTree($published = false, $user = null, $item_count = false) { // get category tree if (empty($this->_category_tree)) { // get categories and item count $categories = $this->getCategories($published, $item_count); $this->_category_tree = CategoryHelper::buildTree($this->id, $categories); } return $this->_category_tree; }
private static function lookForCategory(&$text, $outerTag) { self::$categories = array(); self::$outerTag = $outerTag; $text = preg_replace_callback('/\\[\\[(' . self::$namespaces . '):([^]]+)]]\\n?/i', array('self', 'replaceCallback'), $text); $result = array('text' => $text, 'categories' => self::$categories); $maybeIndex = count(self::$maybeCategory); if ($maybeIndex) { //look for category ending //TODO: this will not catch [[Category:Abc<noinclude>]]</noinclude> if (self::$nodeLevel == self::$maybeCategory[$maybeIndex - 1]['level'] && preg_match('/^([^[]*?]])/', $text, $match)) { $text = preg_replace('/^[^[]*?]]/', '', $text, 1); self::$maybeCategory[$maybeIndex - 1]['end'] = $match[1]; self::$maybeCategory[$maybeIndex - 1]['beginSibblingsBefore'] = self::$maybeCategoryBegin[self::$nodeLevel]; } } if (preg_match('/(\\[\\[(?:' . self::$namespaces . '):.*$)/i', $text, $match)) { self::$maybeCategory[$maybeIndex] = array('namespace' => $match[1], 'begin' => $match[1], 'level' => self::$nodeLevel); self::$maybeCategoryBegin[self::$nodeLevel] = 0; } return $result; }
public function save() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $post = JRequest::get('post'); $db = YDatabase::getInstance(); $tzoffset = JFactory::getConfig()->getValue('config.offset'); $now = JFactory::getDate(); $now->setOffset($tzoffset); $msg = ''; try { $this->_init(); // is this an item edit? $edit = (int) $this->item->id; // is current user the item owner and does the user have sufficient user rights if ($edit && (!$this->item->canAccess($this->user) || $this->item->created_by != $this->user->id)) { throw new YControllerException('You are not allowed to make changes to this item.'); } // get default category - only in none trusted mode $categories = array(); if (!$this->submission->isInTrustedMode() && ($category = $this->submission->getForm($this->type->id)->get('category'))) { $categories[] = $category; } // get element data from post if (isset($post['elements'])) { // filter element data if (!$this->submission->isInTrustedMode() && !UserHelper::isJoomlaAdmin($this->user)) { JRequest::setVar('elements', SubmissionHelper::filterData($post['elements'])); $post = JRequest::get('post'); } // merge elements into post $post = array_merge($post, $post['elements']); } // fix publishing dates in trusted mode if ($this->submission->isInTrustedMode()) { // set publish up date if (isset($post['publish_up'])) { if (empty($post['publish_up'])) { $post['publish_up'] = $now->toMySQL(true); } } // set publish down date if (isset($post['publish_down'])) { if (trim($post['publish_down']) == JText::_('Never') || trim($post['publish_down']) == '') { $post['publish_down'] = $db->getNullDate(); } } } // sanatize tags if (!isset($post['tags'])) { $post['tags'] = array(); } // build new item form and bind it with post data $form = new ItemForm(array('submission' => $this->submission, 'item' => $this->item, 'elements_config' => $this->elements_config)); $form->bind($post); // save item if form is valid if ($form->isValid()) { // set name $this->item->name = $form->getValue('name'); // bind elements foreach ($this->elements_config as $data) { if (($element = $this->item->getElement($data->element)) && ($field = $form->getFormField($data->element))) { if ($field_data = $field->hasError() ? $field->getTaintedValue() : $field->getValue()) { $element->bindData($field_data); } else { $element->bindData(); } // perform submission uploads if ($element instanceof iSubmissionUpload) { $element->doUpload(); } } } // set alias $this->item->alias = ItemHelper::getUniqueAlias($this->item->id, YString::sluggify($this->item->name)); // set modified $this->item->modified = $now->toMySQL(); $this->item->modified_by = $this->user->get('id'); // creating new item if (!$edit) { // set state $this->item->state = 0; // set created date $this->item->created = $now->toMySQL(); $this->item->created_by = $this->user->get('id'); $this->item->created_by_alias = ''; // set publish up - publish down $this->item->publish_up = $now->toMySQL(); $this->item->publish_down = $db->getNullDate(); // set access $this->item->access = 0; // set searchable $this->item->searchable = 1; } if ($this->submission->isInTrustedMode()) { // set state $this->item->state = $form->getValue('state'); // set publish up if (($publish_up = $form->getValue('publish_up')) && !empty($publish_up)) { $date = JFactory::getDate($publish_up, $tzoffset); $publish_up = $date->toMySQL(); } $this->item->publish_up = $publish_up; // set publish down if (($publish_down = $form->getValue('publish_down')) && !empty($publish_down) && !($publish_down == $db->getNullDate())) { $date = JFactory::getDate($publish_down, $tzoffset); $publish_down = $date->toMySQL(); } $this->item->publish_down = $publish_down; // set searchable $this->item->searchable = $form->getValue('searchable'); // set comments enabled $this->item->params = $this->item->getParams()->set('config.enable_comments', $form->getValue('enable_comments'))->toString(); // set frontpage if ($form->getValue('frontpage')) { $categories[] = 0; } // set categories $tmp_categories = $form->getValue('categories'); if (!empty($tmp_categories)) { foreach ($form->getValue('categories') as $category) { $categories[] = $category; } } // set tags $tags = $form->hasError('tags') ? $form->getTaintedValue('tags') : $form->getValue('tags'); $this->item->setTags($tags); } else { // spam protection - user may only submit items every SubmissionController::TIME_BETWEEN_PUBLIC_SUBMISSIONS seconds if (!$edit) { $timestamp = $this->session->get('ZOO_LAST_SUBMISSION_TIMESTAMP'); $now = time(); if ($now < $timestamp + SubmissionController::TIME_BETWEEN_PUBLIC_SUBMISSIONS) { throw new SubmissionControllerException('You are submitting to fast, please try again in a few moments.'); } $this->session->set('ZOO_LAST_SUBMISSION_TIMESTAMP', $now); } } // save item YTable::getInstance('item')->save($this->item); // save category relations - only if editing in trusted mode if (!$edit || $this->submission->isInTrustedMode()) { CategoryHelper::saveCategoryItemRelations($this->item->id, $categories); } // set redirect message $msg = $this->submission->isInTrustedMode() ? JText::_('Thanks for your submission.') : JText::_('Thanks for your submission. It will be reviewed before being posted on the site.'); // add form to session if form is not valid } else { $this->addFormToSession($form); } } catch (SubmissionControllerException $e) { // raise warning on exception JError::raiseWarning(0, (string) $e); } catch (YException $e) { // raise warning on exception JError::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) { JError::raiseWarning(0, (string) $e); } } // redirect to mysubmissions if ($this->redirect == 'mysubmissions' && $form && $form->isValid()) { $link = RouteHelper::getMySubmissionsRoute($this->submission); // redirect to edit form } else { $link = RouteHelper::getSubmissionRoute($this->submission, $this->type->id, $this->hash, $this->item_id, $this->redirect); } $link = JRoute::_($link, false); $this->setRedirect($link, $msg); }
public static function categoryList($application, $options, $name, $attribs = null, $key = 'value', $text = 'text', $selected = NULL, $idtag = false, $translate = false) { // set options if (is_array($options)) { reset($options); } else { $options = array($options); } // get category tree list $list = CategoryHelper::buildTreeList(0, $application->getCategoryTree(), array(), '- ', '. ', ' '); // create options foreach ($list as $category) { $options[] = JHTML::_('select.option', $category->id, $category->treename); } return JHTML::_('select.genericlist', $options, $name, $attribs, $key, $text, $selected, $idtag, $translate); }
/** * Return wikitext */ public function getWikitextFromRequest() { // "wikitext" field used when generating preview / diff $wikitext = $this->request->getText('wikitext'); $method = $this->request->getVal('method', ''); if ($wikitext == '') { if ($method == 'preview' || $method == 'diff') { $wikitext = $this->getWikitextFromField('content'); // Add categories to wikitext for preview and diff if (!empty($this->app->wg->EnableCategorySelectExt)) { $categories = $this->request->getVal('categories', ''); if (!empty($categories)) { $wikitext .= CategoryHelper::changeFormat($categories, 'json', 'wikitext'); } } // "wpTextbox1" field used when submitting editpage // (needs to be processed by Reverse Parser if saved from wysiwyg mode) } else { $wikitext = $this->getWikitextFromField('wpTextbox1'); } } return $wikitext; }
/** * @desc Alias to CategoryHelper::extractCategoriesFromWikitext helpful for unit tests * * @param $wikitext * @return Array */ public static function getCategoriesFromCategorySelect($wikitext) { return CategoryHelper::extractCategoriesFromWikitext($wikitext, true); }
function ZooParseRoute($segments) { // 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) CategoryHelper::translateAliasToID($segments[1]); } if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; $vars['category_id'] = (int) CategoryHelper::translateAliasToID($segments[1]); $vars['page'] = (int) $segments[2]; } // alpha index (with optional pagination) $task = 'alphaindex'; if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; $vars['app_id'] = (int) ApplicationHelper::translateAliasToID($segments[1]); $vars['alpha_char'] = (string) $segments[2]; } if ($count == 4 && $segments[0] == $task) { $vars['task'] = $task; $vars['app_id'] = (int) ApplicationHelper::translateAliasToID($segments[1]); $vars['alpha_char'] = (string) $segments[2]; $vars['page'] = (int) $segments[3]; } // tag (with optional pagination) $task = 'tag'; if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; $vars['app_id'] = (int) ApplicationHelper::translateAliasToID($segments[1]); $vars['tag'] = (string) $segments[2]; } if ($count == 4 && $segments[0] == $task) { $vars['task'] = $task; $vars['app_id'] = (int) ApplicationHelper::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) ItemHelper::translateAliasToID($segments[1]); } // feed $task = 'feed'; if ($count == 3 && $segments[0] == $task) { $vars['task'] = $task; $vars['type'] = (string) $segments[1]; $vars['app_id'] = (string) $segments[2]; } if ($count == 4 && $segments[0] == $task) { $vars['task'] = $task; $vars['type'] = (string) $segments[1]; $vars['app_id'] = (string) $segments[2]; $vars['category_id'] = (int) CategoryHelper::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) SubmissionHelper::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) SubmissionHelper::translateAliasToID($segments[2]); $vars['type_id'] = (string) $segments[3]; $vars['submission_hash'] = (string) $segments[4]; $vars['item_id'] = (int) ItemHelper::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) SubmissionHelper::translateAliasToID($segments[2]); } return $vars; }