本文整理汇总了PHP中KunenaRoute::stringURLSafe方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaRoute::stringURLSafe方法的具体用法?PHP KunenaRoute::stringURLSafe怎么用?PHP KunenaRoute::stringURLSafe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaRoute
的用法示例。
在下文中一共展示了KunenaRoute::stringURLSafe方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMenu
/**
* Create a Joomla menu for the main
* navigation tab and publish it in the Kunena module position kunena_menu.
* In addition it checks if there is a link to Kunena in any of the menus
* and if not, adds a forum link in the mainmenu.
*/
function createMenu()
{
$menu = array('name' => JText::_('COM_KUNENA_MENU_ITEM_FORUM'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_FORUM_ALIAS'), 'forum'), 'link' => 'index.php?option=com_kunena&view=home', 'access' => 0, 'params' => array('catids' => 0));
$submenu = array('index' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_INDEX'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_INDEX_ALIAS'), 'index'), 'link' => 'index.php?option=com_kunena&view=category&layout=list', 'access' => 0, 'default' => 'categories', 'params' => array()), 'recent' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_RECENT'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_RECENT_ALIAS'), 'recent'), 'link' => 'index.php?option=com_kunena&view=topics&mode=replies', 'access' => 0, 'default' => 'recent', 'params' => array('topics_catselection' => 1, 'topics_categories' => 0, 'topics_time' => 720)), 'newtopic' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_NEWTOPIC'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_NEWTOPIC_ALIAS'), 'newtopic'), 'link' => 'index.php?option=com_kunena&view=topic&layout=create', 'access' => 1, 'params' => array()), 'noreplies' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_NOREPLIES'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_NOREPLIES_ALIAS'), 'noreplies'), 'link' => 'index.php?option=com_kunena&view=topics&mode=noreplies', 'access' => 1, 'params' => array('topics_catselection' => 1, 'topics_categories' => 0, 'topics_time' => -1)), 'mylatest' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_MYLATEST'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_MYLATEST_ALIAS'), 'mylatest'), 'link' => 'index.php?option=com_kunena&view=topics&layout=user&mode=default', 'access' => 1, 'default' => 'my', 'params' => array('topics_catselection' => 1, 'topics_categories' => 0, 'topics_time' => -1)), 'profile' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_PROFILE'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_PROFILE_ALIAS'), 'profile'), 'link' => 'index.php?option=com_kunena&view=user', 'access' => 1, 'params' => array('integration' => 1)), 'help' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_HELP'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_HELP_ALIAS'), 'help'), 'link' => 'index.php?option=com_kunena&view=misc', 'access' => 2, 'params' => array('body' => JText::_('COM_KUNENA_MENU_HELP_BODY'), 'body_format' => 'bbcode')), 'search' => array('name' => JText::_('COM_KUNENA_MENU_ITEM_SEARCH'), 'alias' => KunenaRoute::stringURLSafe(JText::_('COM_KUNENA_MENU_SEARCH_ALIAS'), 'search'), 'link' => 'index.php?option=com_kunena&view=search', 'access' => 0, 'params' => array()));
$lang = JFactory::getLanguage();
$debug = $lang->setDebug(false);
if (version_compare(JVERSION, '1.6', '>')) {
// Joomla 1.6+
$this->createMenuJ25($menu, $submenu);
} else {
// Joomla 1.5
$this->createMenuJ15($menu, $submenu);
}
KunenaMenuHelper::cleanCache();
$lang->setDebug($debug);
}
示例2: KunenaBuildRoute
/**
* Build SEF URL
*
* All SEF URLs are formatted like this:
*
* http://site.com/menuitem/1-category-name/10-subject/[view]/[layout]/[param1]-value1/[param2]-value2?param3=value3¶m4=value4
*
* - If catid exists, category will always be in the first segment
* - If there is no catid, second segment for message will not be used (param-value: id-10)
* - [view] and [layout] are the only parameters without value
* - all other segments (task, id, userid, page, sel) are using param-value format
*
* NOTE! Only major variables are using SEF segments
*
* @param $query
* @return array Segments
*/
function KunenaBuildRoute(&$query)
{
$segments = array();
// If Kunena Forum isn't installed or SEF is not enabled, do nothing
if (!class_exists('KunenaForum') || !KunenaForum::isCompatible('3.0') || !KunenaForum::installed() || !KunenaRoute::$config->sef) {
return $segments;
}
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __FUNCTION__ . '()') : null;
// Get menu item
$menuitem = null;
if (isset($query['Itemid'])) {
static $menuitems = array();
$Itemid = $query['Itemid'] = (int) $query['Itemid'];
if (!isset($menuitems[$Itemid])) {
$menuitems[$Itemid] = JFactory::getApplication()->getMenu()->getItem($Itemid);
if (!$menuitems[$Itemid]) {
// Itemid doesn't exist or is invalid
unset($query['Itemid']);
}
}
$menuitem = $menuitems[$Itemid];
}
// Safety check: we need view in order to create SEF URLs
if (!isset($menuitem->query['view']) && empty($query['view'])) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __FUNCTION__ . '()') : null;
return $segments;
}
// Get view for later use (query wins menu item)
$view = isset($query['view']) ? (string) preg_replace('/[^a-z]/', '', $query['view']) : $menuitem->query['view'];
// Get default values for URI variables
if (isset(KunenaRoute::$views[$view])) {
$defaults = KunenaRoute::$views[$view];
}
// Check all URI variables and remove those which aren't needed
foreach ($query as $var => $value) {
if (isset($defaults[$var]) && !isset($menuitem->query[$var]) && $value == $defaults[$var]) {
// Remove URI variable which has default value
unset($query[$var]);
} elseif (isset($menuitem->query[$var]) && $value == $menuitem->query[$var] && $var != 'Itemid' && $var != 'option') {
// Remove URI variable which has the same value as menu item
unset($query[$var]);
}
}
// We may have catid also in the menu item (it will not be in URI)
$numeric = !empty($menuitem->query['catid']);
// Support URIs like: /forum/12-my_category
if (!empty($query['catid']) && ($view == 'category' || $view == 'topic' || $view == 'home')) {
// TODO: ensure that we have view=category/topic
$catid = (int) $query['catid'];
if ($catid) {
$numeric = true;
$alias = KunenaForumCategoryHelper::get($catid)->alias;
// If category alias is empty, use category id; otherwise use alias
$segments[] = empty($alias) ? $catid : $alias;
// This segment fully defines category view so the variable is no longer needed
if ($view == 'category') {
unset($query['view']);
}
}
unset($query['catid']);
}
// Support URIs like: /forum/12-category/123-topic
if (!empty($query['id']) && $numeric) {
$id = (int) $query['id'];
if ($id) {
$subject = KunenaRoute::stringURLSafe(KunenaForumTopicHelper::get($id)->subject);
if (empty($subject)) {
$segments[] = $id;
} else {
$segments[] = "{$id}-{$subject}";
}
// This segment fully defines topic view so the variable is no longer needed
if ($view == 'topic') {
unset($query['view']);
}
}
unset($query['id']);
} else {
// No id available, do not use numeric variable for mesid
$numeric = false;
}
// View gets added only when we do not use short URI for category/topic
if (!empty($query['view'])) {
//.........这里部分代码省略.........
示例3: installSampleData
function installSampleData()
{
$lang = JFactory::getLanguage();
$debug = $lang->setDebug(false);
jimport('joomla.utilities.date');
$db = JFactory::getDBO();
$posttime = new JDate();
$my = JFactory::getUser();
$queries = array();
$query = "INSERT INTO `#__kunena_aliases` (`alias`, `type`, `item`, `state`) VALUES\n\t('announcement', 'view', 'announcement', 1),\n\t('category', 'view', 'category', 1),\n\t('common', 'view', 'common', 1),\n\t('credits', 'view', 'credits', 1),\n\t('home', 'view', 'home', 1),\n\t('misc', 'view', 'misc', 1),\n\t('search', 'view', 'search', 1),\n\t('statistics', 'view', 'statistics', 1),\n\t('topic', 'view', 'topic', 1),\n\t('topics', 'view', 'topics', 1),\n\t('user', 'view', 'user', 1),\n\t('category/create', 'layout', 'category.create', 1),\n\t('create', 'layout', 'category.create', 0),\n\t('category/default', 'layout', 'category.default', 1),\n\t('default', 'layout', 'category.default', 0),\n\t('category/edit', 'layout', 'category.edit', 1),\n\t('edit', 'layout', 'category.edit', 0),\n\t('category/manage', 'layout', 'category.manage', 1),\n\t('manage', 'layout', 'category.manage', 0),\n\t('category/moderate', 'layout', 'category.moderate', 1),\n\t('moderate', 'layout', 'category.moderate', 0),\n\t('category/user', 'layout', 'category.user', 1);";
$queries[] = array('kunena_aliases', $query);
$query = "INSERT INTO `#__kunena_ranks`\n\t(`rank_id`, `rank_title`, `rank_min`, `rank_special`, `rank_image`) VALUES\n\t(1, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK1'))}, 0, 0, 'rank1.gif'),\n\t(2, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK2'))}, 20, 0, 'rank2.gif'),\n\t(3, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK3'))}, 40, 0, 'rank3.gif'),\n\t(4, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK4'))}, 80, 0, 'rank4.gif'),\n\t(5, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK5'))}, 160, 0, 'rank5.gif'),\n\t(6, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK6'))}, 320, 0, 'rank6.gif'),\n\t(7, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_ADMIN'))}, 0, 1, 'rankadmin.gif'),\n\t(8, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_MODERATOR'))}, 0, 1, 'rankmod.gif'),\n\t(9, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_SPAMMER'))}, 0, 1, 'rankspammer.gif'),\n\t(10, {$db->quote(KText::_('COM_KUNENA_SAMPLEDATA_RANK_BANNED'))}, 0, 1, 'rankbanned.gif');";
$queries[] = array('kunena_ranks', $query);
$query = "INSERT INTO `#__kunena_smileys`\n\t(`id`,`code`,`location`,`greylocation`,`emoticonbar`) VALUES\n\t(1, 'B)', 'cool.png', 'cool-grey.png', 1),\n\t(2, '8)', 'cool.png', 'cool-grey.png', 0),\n\t(3, '8-)', 'cool.png', 'cool-grey.png', 0),\n\t(4, ':-(', 'sad.png', 'sad-grey.png', 0),\n\t(5, ':(', 'sad.png', 'sad-grey.png', 1),\n\t(6, ':sad:', 'sad.png', 'sad-grey.png', 0),\n\t(7, ':cry:', 'sad.png', 'sad-grey.png', 0),\n\t(8, ':)', 'smile.png', 'smile-grey.png', 1),\n\t(9, ':-)', 'smile.png', 'smile-grey.png', 0),\n\t(10, ':cheer:', 'cheerful.png', 'cheerful-grey.png', 1),\n\t(11, ';)', 'wink.png', 'wink-grey.png', 1),\n\t(12, ';-)', 'wink.png', 'wink-grey.png', 0),\n\t(13, ':wink:', 'wink.png', 'wink-grey.png', 0),\n\t(14, ';-)', 'wink.png', 'wink-grey.png', 0),\n\t(15, ':P', 'tongue.png', 'tongue-grey.png', 1),\n\t(16, ':p', 'tongue.png', 'tongue-grey.png', 0),\n\t(17, ':-p', 'tongue.png', 'tongue-grey.png', 0),\n\t(18, ':-P', 'tongue.png', 'tongue-grey.png', 0),\n\t(19, ':razz:', 'tongue.png', 'tongue-grey.png', 0),\n\t(20, ':angry:', 'angry.png', 'angry-grey.png', 1),\n\t(21, ':mad:', 'angry.png', 'angry-grey.png', 0),\n\t(22, ':unsure:', 'unsure.png', 'unsure-grey.png', 1),\n\t(23, ':o', 'shocked.png', 'shocked-grey.png', 0),\n\t(24, ':-o', 'shocked.png', 'shocked-grey.png', 0),\n\t(25, ':O', 'shocked.png', 'shocked-grey.png', 0),\n\t(26, ':-O', 'shocked.png', 'shocked-grey.png', 0),\n\t(27, ':eek:', 'shocked.png', 'shocked-grey.png', 0),\n\t(28, ':ohmy:', 'shocked.png', 'shocked-grey.png', 1),\n\t(29, ':huh:', 'wassat.png', 'wassat-grey.png', 1),\n\t(30, ':?', 'confused.png', 'confused-grey.png', 0),\n\t(31, ':-?', 'confused.png', 'confused-grey.png', 0),\n\t(32, ':???', 'confused.png', 'confused-grey.png', 0),\n\t(33, ':dry:', 'ermm.png', 'ermm-grey.png', 1),\n\t(34, ':ermm:', 'ermm.png', 'ermm-grey.png', 0),\n\t(35, ':lol:', 'grin.png', 'grin-grey.png', 1),\n\t(36, ':X', 'sick.png', 'sick-grey.png', 0),\n\t(37, ':x', 'sick.png', 'sick-grey.png', 0),\n\t(38, ':sick:', 'sick.png', 'sick-grey.png', 1),\n\t(39, ':silly:', 'silly.png', 'silly-grey.png', 1),\n\t(40, ':y32b4:', 'silly.png', 'silly-grey.png', 0),\n\t(41, ':blink:', 'blink.png', 'blink-grey.png', 1),\n\t(42, ':blush:', 'blush.png', 'blush-grey.png', 1),\n\t(43, ':oops:', 'blush.png', 'blush-grey.png', 1),\n\t(44, ':kiss:', 'kissing.png', 'kissing-grey.png', 1),\n\t(45, ':rolleyes:', 'blink.png', 'blink-grey.png', 0),\n\t(46, ':roll:', 'blink.png', 'blink-grey.png', 0),\n\t(47, ':woohoo:', 'w00t.png', 'w00t-grey.png', 1),\n\t(48, ':side:', 'sideways.png', 'sideways-grey.png', 1),\n\t(49, ':S', 'dizzy.png', 'dizzy-grey.png', 1),\n\t(50, ':s', 'dizzy.png', 'dizzy-grey.png', 0),\n\t(51, ':evil:', 'devil.png', 'devil-grey.png', 1),\n\t(52, ':twisted:', 'devil.png', 'devil-grey.png', 0),\n\t(53, ':whistle:', 'whistling.png', 'whistling-grey.png', 1),\n\t(54, ':pinch:', 'pinch.png', 'pinch-grey.png', 1),\n\t(55, ':D', 'laughing.png', 'laughing-grey.png', 0),\n\t(56, ':-D', 'laughing.png', 'laughing-grey.png', 0),\n\t(57, ':grin:', 'laughing.png', 'laughing-grey.png', 0),\n\t(58, ':laugh:', 'laughing.png', 'laughing-grey.png', 0),\n\t(59, ':|', 'neutral.png', 'neutral-grey.png', 0),\n\t(60, ':-|', 'neutral.png', 'neutral-grey.png', 0),\n\t(61, ':neutral:', 'neutral.png', 'neutral-grey.png', 0),\n\t(62, ':mrgreen:', 'mrgreen.png', 'mrgreen-grey.png', 0),\n\t(63, ':?:', 'question.png', 'question-grey.png', 0),\n\t(64, ':!:', 'exclamation.png', 'exclamation-grey.png', 0),\n\t(65, ':arrow:', 'arrow.png', 'arrow-grey.png', 0),\n\t(66, ':idea:', 'idea.png', 'idea-grey.png', 0)";
$queries[] = array('kunena_smileys', $query);
$section = KText::_('COM_KUNENA_SAMPLEDATA_SECTION_TITLE');
$cat1 = KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_TITLE');
$cat2 = KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_TITLE');
$section_alias = KunenaRoute::stringURLSafe(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_TITLE'), 'main-forum');
$cat1_alias = KunenaRoute::stringURLSafe(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_TITLE'), 'welcome-mat');
$cat2_alias = KunenaRoute::stringURLSafe(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_TITLE'), 'suggestion-box');
$aliasquery = "INSERT INTO `#__kunena_aliases` (`alias`, `type`, `item`, `state`) VALUES\n\t\t({$db->quote($section_alias)}, 'catid', '1', 1),\n\t\t({$db->quote($cat1_alias)}, 'catid', '2', 1),\n\t\t({$db->quote($cat2_alias)}, 'catid', '3', 1);";
$query = "INSERT INTO `#__kunena_categories`\n\t\t(`id`, `parent_id`, `name`, `alias`, `pub_access`, `ordering`, `published`, `description`, `headerdesc`, `numTopics`, `numPosts`, `allow_polls`, `last_topic_id`, `last_post_id`, `last_post_time`, `accesstype`) VALUES\n\t\t(1, 0, {$db->quote($section)}, {$db->quote($section_alias)}, 1, 1, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_SECTION_HEADER')) . ", 0, 0, 0, 0, 0, 0, 'joomla.group'),\n\t\t(2, 1, {$db->quote($cat1)}, {$db->quote($cat1_alias)}, 1, 1, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY1_HEADER')) . ", 1 , 1, 0, 1, 1, {$posttime->toUnix()}, 'joomla.group'),\n\t\t(3, 1, {$db->quote($cat2)}, {$db->quote($cat2_alias)}, 1, 2, 1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_DESC')) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_CATEGORY2_HEADER')) . ", 0 , 0, 1, 0, 0, 0, 'joomla.group');";
$queries[] = array('kunena_categories', $query);
$query = "INSERT INTO `#__kunena_messages`\n\t(`id`, `parent`, `thread`, `catid`, `userid`, `name`, `subject`, `time`, `ip`) VALUES\n\t(1, 0, 1, 2, " . $db->quote($my->id) . ", 'Kunena', " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_POST_WELCOME_SUBJECT')) . ", " . $posttime->toUnix() . ", '127.0.0.1');";
$queries[] = array('kunena_messages', $query);
$query = "INSERT INTO `#__kunena_messages_text`\n\t(`mesid`, `message`) VALUES\n\t(1, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_POST_WELCOME_TEXT_CONTENT')) . ");";
$queries[] = array('kunena_messages_text', $query);
$query = "INSERT INTO `#__kunena_topics`\n\t(`id`, `category_id`, `subject`, `posts`, `first_post_id`, `first_post_time`, `first_post_userid`, `first_post_message`, `first_post_guest_name`, `last_post_id`, `last_post_time`, `last_post_userid`, `last_post_message`, `last_post_guest_name`) VALUES\n\t(1, 2, " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_POST_WELCOME_SUBJECT')) . ", 1, 1, " . $posttime->toUnix() . ", " . $db->quote($my->id) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_POST_WELCOME_TEXT_CONTENT')) . ", 'Kunena', 1, " . $posttime->toUnix() . ", " . $db->quote($my->id) . ", " . $db->quote(KText::_('COM_KUNENA_SAMPLEDATA_POST_WELCOME_TEXT_CONTENT')) . ", 'Kunena');";
$queries[] = array('kunena_topics', $query);
$counter = 0;
foreach ($queries as $query) {
// Only insert sample/default data if table is empty
$db->setQuery("SELECT * FROM " . $db->quoteName($db->getPrefix() . $query[0]), 0, 1);
$filled = $db->loadObject();
if (!$filled) {
$db->setQuery($query[1]);
$db->query();
if ($db->getErrorNum()) {
throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum());
}
if ($query[0] == 'kunena_categories') {
$db->setQuery($aliasquery);
$db->query();
if ($db->getErrorNum()) {
throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum());
}
}
$counter++;
}
}
$lang->setDebug($debug);
// Insert missing users
$query = "INSERT INTO #__kunena_users (userid, showOnline) SELECT a.id AS userid, 1 AS showOnline FROM #__users AS a LEFT JOIN #__kunena_users AS b ON b.userid=a.id WHERE b.userid IS NULL";
$db->setQuery($query);
$db->query();
if ($db->getErrorNum()) {
throw new KunenaInstallerException($db->getErrorMsg(), $db->getErrorNum());
}
return $counter;
}
示例4: check
/**
* @see KunenaDatabaseObject::check()
*/
public function check()
{
$this->alias = trim($this->alias);
if (empty($this->alias)) {
$this->alias = $this->name;
}
if ($this->alias != $this->_alias) {
$this->alias = KunenaRoute::stringURLSafe($this->alias);
if ($this->checkAlias($this->alias) === false) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_FORUM_CATEGORY_ERROR_ALIAS_RESERVED', $this->alias));
return false;
}
}
return true;
}
示例5: createIndexerResult
protected function createIndexerResult($message)
{
// Convert the item to a result object.
$item = new FinderIndexerResult();
$item->id = $message->id;
$item->catid = $message->catid;
// Set title context.
$item->title = $message->subject;
// Build the necessary url, route, path and alias information.
$item->url = $this->getUrl($message->id, $this->extension, $this->layout);
$item->route = $item->url . '&Itemid=' . KunenaRoute::getItemId($item->url);
$item->path = FinderIndexerHelper::getContentPath($item->url);
//route);
$item->alias = KunenaRoute::stringURLSafe($message->subject);
// Set body context.
$item->body = KunenaHtmlParser::stripBBCode($message->message);
$item->summary = $item->body;
// Set other information.
$item->published = intval($message->hold == 0);
// TODO: add topic state
//$item->state = intval($message->getCategory()->published == 1);
$item->state = $item->published;
$item->language = '*';
// TODO: add access control
$item->access = $this->getAccessLevel($item);
// Set the item type.
$item->type_id = $this->type_id;
// Set the mime type.
$item->mime = $this->mime;
// Set the item layout.
$item->layout = $this->layout;
return $item;
}
示例6: execute
//.........这里部分代码省略.........
}
continue;
}
$subject = $trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );
$topic = KunenaForumMessageHelper::get( $topicId );
$fields = array( 'message' => $message );
if ( $subject ) {
$fields['subject'] = $subject;
}
$topic->newReply( $fields, $owner );
break;
case 'topic':
if ( ! $owner ) {
if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_OWNER', ':: Action [action] :: Kunena skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
}
continue;
}
$subject = $trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );
if ( ! $subject ) {
if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_SUBJ', ':: Action [action] :: Kunena skipped due to missing subject', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
}
continue;
}
$message = $trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );
if ( ! $message ) {
if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_MSG', ':: Action [action] :: Kunena skipped due to missing message', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
}
continue;
}
$categoryId = (int) $row->get( 'category', 0, GetterInterface::INT );
if ( ! $categoryId ) {
if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_CAT', ':: Action [action] :: Kunena skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
}
continue;
}
$category = KunenaForumCategoryHelper::get( $categoryId );
$fields = array( 'catid' => $categoryId,
'subject' => $subject,
'message' => $message
);
$category->newTopic( $fields, $owner );
break;
case 'category':
default:
$name = $trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) );
if ( ! $name ) {
if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_NAME', ':: Action [action] :: Kunena skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
}
continue;
}
$query = 'SELECT ' . $_CB_database->NameQuote( 'id' )
. "\n FROM " . $_CB_database->NameQuote( '#__kunena_categories' )
. "\n WHERE " . $_CB_database->NameQuote( 'name' ) . " = " . $_CB_database->Quote( $name );
$_CB_database->setQuery( $query );
if ( ! $_CB_database->loadResult() ) {
$category = KunenaForumCategoryHelper::get();
$category->set( 'parent_id', (int) $row->get( 'parent', 0, GetterInterface::INT ) );
$category->set( 'name', $name );
$category->set( 'alias', KunenaRoute::stringURLSafe( $name ) );
$category->set( 'accesstype', 'joomla.group' );
$category->set( 'access', (int) $row->get( 'access', 1, GetterInterface::INT ) );
$category->set( 'published', (int) $row->get( 'published', 1, GetterInterface::INT ) );
$category->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) );
if ( $category->save() && $owner ) {
$category->addModerator( (int) $owner );
}
}
break;
}
}
}
示例7: foreach
/**
* Export sections and categories
*
* Returns list of category objects containing database fields
* to #__kunena_categories.
* All categories without parent are sections.
*
* NOTE: it's very important to keep category IDs (containing topics) the same!
* If there are two tables for sections and categories, change IDs on sections..
*
* @param int $start Pagination start
* @param int $limit Pagination limit
* @return array
*/
public function &exportCategories($start = 0, $limit = 0)
{
$query = "SELECT\n\t\t\tforum_id AS id,\n\t\t\tparent_id AS parent_id,\n\t\t\tforum_name AS name,\n\t\t\tforum_name AS alias,\n\t\t\t0 AS icon_id,\n\t\t\t(forum_status=1) AS locked,\n\t\t\t'joomla.level' AS accesstype,\n\t\t\t0 AS access,\n\t\t\t0 AS pub_access,\n\t\t\t1 AS pub_recurse,\n\t\t\t0 AS admin_access,\n\t\t\t1 AS admin_recurse,\n\t\t\tleft_id AS ordering,\n\t\t\t1 AS published,\n\t\t\tnull AS channels,\n\t\t\t0 AS checked_out,\n\t\t\t'0000-00-00 00:00:00' AS checked_out_time,\n\t\t\t0 AS review,\n\t\t\t0 AS allow_anonymous,\n\t\t\t0 AS post_anonymous,\n\t\t\t0 AS hits,\n\t\t\tforum_desc AS description,\n\t\t\tforum_rules AS headerdesc,\n\t\t\t'' AS class_sfx,\n\t\t\t1 AS allow_polls,\n\t\t\t'' AS topic_ordering,\n\t\t\tforum_posts AS numPosts,\n\t\t\tforum_topics_real AS numTopics,\n\t\t\t0 AS last_topic_id,\n\t\t\tforum_last_post_id AS last_post_id,\n\t\t\tforum_last_post_time AS last_post_time,\n\t\t\t(LENGTH(forum_desc_bitfield)>0) AS bbcode_desc,\n\t\t\t(LENGTH(forum_rules_bitfield)>0) AS bbcode_header,\n\t\t\t'' AS params\n\t\tFROM #__forums ORDER BY id";
$result = $this->getExportData($query, $start, $limit, 'id');
foreach ($result as &$row) {
$this->parseText($row->name);
// FIXME: joomla level in J2.5
// FIXME: remove id
$row->alias = KunenaRoute::stringURLSafe("{$row->id}-{$row->alias}");
if ($row->bbcode_desc) {
$this->parseBBCode($row->description);
} else {
$this->parseText($row->description);
}
if ($row->bbcode_header) {
$this->parseBBCode($row->headerdesc);
} else {
$this->parseText($row->headerdesc);
}
}
return $result;
}
示例8: saveForum
static public function saveForum( $parentForum, $row, $user, $plugin ) {
if ( ! class_exists( 'KunenaForumCategoryHelper' ) ) {
return;
}
if ( $parentForum ) {
if ( method_exists( $row, 'getCategory' ) ) {
$authorized = cbgjClass::getAuthorization( $row->getCategory(), $row, $user );
} else {
$authorized = cbgjClass::getAuthorization( $row, null, $user );
}
$params = $row->getParams();
$forum = $params->get( 'forum_id', null );
if ( ! $forum ) {
$forum = cbgjForumsModel::setForum( $parentForum, $row, $user, $plugin );
} else {
$exists = KunenaForumCategoryHelper::get( (int) $forum );
if ( ! $exists->name ) {
$forum = cbgjForumsModel::setForum( $parentForum, $row, $user, $plugin );
}
}
if ( $forum ) {
$forumShow = (int) cbgjClass::getCleanParam( ( $plugin->params->get( 'forum_show_config', 1 ) || cbgjClass::hasAccess( 'usr_mod', $authorized ) ), 'forum_show', $params->get( 'forum_show', $plugin->params->get( 'forum_show', 1 ) ) );
$category = KunenaForumCategoryHelper::get( (int) $forum );
if ( method_exists( $row, 'getCategory' ) ) {
$alias = null;
if ( $row->get( 'parent' ) ) {
$alias .= $row->get( 'parent' ) . ' ';
}
$alias .= $row->get( 'id' ) . ' ' . $row->getName();
} else {
$alias = $row->get( 'category' ) . ' ';
if ( $row->get( 'parent' ) ) {
$alias .= $row->get( 'parent' ) . ' ';
}
$alias .= $row->get( 'id' ) . ' ' . $row->getName();
}
$category->set( 'parent_id', (int) $parentForum );
$category->set( 'name', str_replace( '&', '&', $row->getName() ) );
$category->set( 'alias', KunenaRoute::stringURLSafe( $alias ) );
$category->set( 'accesstype', 'communitybuilder' );
$category->set( 'access', (int) $row->get( 'id' ) );
$category->set( 'published', (int) ( ! $forumShow ? 0 : $row->get( 'published' ) ) );
$category->set( 'description', $row->getDescription() );
if ( ! $category->save() ) {
trigger_error( CBTxt::P( '[element] - saveForum SQL Error: [error]', array( '[element]' => $plugin->element, '[error]' => $category->getError() ) ) );
} else {
$params->set( 'forum_id', (int) $category->id );
$params->set( 'forum_show', (int) $forumShow );
$params->set( 'forum_public', (int) cbgjClass::getCleanParam( ( $plugin->params->get( 'forum_public_config', 1 ) || cbgjClass::hasAccess( 'usr_mod', $authorized ) ), 'forum_public', $params->get( 'forum_public', $plugin->params->get( 'forum_public', 1 ) ) ) );
if ( ! $row->storeParams( $params ) ) {
trigger_error( CBTxt::P( '[element] - saveForum SQL Error: [error]', array( '[element]' => $plugin->element, '[error]' => $row->getError() ) ) );
}
$category->addModerator( (int) $row->user_id );
}
}
}
}