public function display($tpl = null) { global $option, $mainframe; $user =& JFactory::getUser(); $model = KFactory::get('admin::com.duuka.model.item'); $item = $model->getItem(); // fail if checked out not by 'me' if ($model->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The weblink'), $item->name); $mainframe->redirect('index.php?option=' . $option, $msg); } /* * We need to unify the introtext and fulltext fields and have the * fields separated by the {readmore} tag, so lets do that now. */ if (JString::strlen($item->fulltext) > 1) { $item->text = $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext; } else { $item->text = $item->introtext; } // Mixin a menubar object $this->mixin(new DuukaMixinMenu($this)); $this->displayMenutitle(); $this->displayToolbar(); $this->displayMenubar(); JRequest::setVar('hidemainmenu', 1); $this->assignRef('item', $item); // Display the layout parent::display($tpl); }
public static function addCard(&$blog, $rawIntroText) { $cfg = EasyBlogHelper::getConfig(); // @rule: Check if user really wants to append the opengraph tags on the headers. if (!$cfg->get('main_twitter_cards')) { return false; } // Get the absolute permalink for this blog item. $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); // Get the image of the blog post. $image = self::getImage($blog, $rawIntroText); // @task: Get Joomla's document object. $doc = JFactory::getDocument(); // Add card definition. $doc->addCustomTag('<meta property="twitter:card" content="summary" />'); $doc->addCustomTag('<meta property="twitter:url" content="' . $url . '" />'); $doc->addCustomTag('<meta property="twitter:title" content="' . $blog->title . '" />'); $text = EasyBlogHelper::stripEmbedTags($rawIntroText); $text = strip_tags($text); $text = str_ireplace("\r\n", "", $text); // Remove any " in the content as this would mess up the headers. $text = str_ireplace('"', '', $text); $maxLength = 137; if (!empty($maxLength)) { $text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text; } $text = EasyBlogStringHelper::escape($text); $doc->addCustomTag('<meta property="twitter:description" content="' . $text . '" />'); if ($image) { $doc->addCustomTag('<meta property="twitter:image" content="' . $image . '"/> '); } return true; }
/** * Description * * @param string SQL with ordering As value and 'name field' AS text * @param integer The length of the truncated headline * @since 1.5 */ function genericordering($sql, $chop = '30') { $db =& JFactory::getDBO(); $order = array(); $db->setQuery($sql); if (!($orders = $db->loadObjectList())) { if ($db->getErrorNum()) { echo $db->stderr(); return false; } else { $order[] = JHTML::_('select.option', 1, JText::_('first')); return $order; } } $order[] = JHTML::_('select.option', 0, '0 ' . JText::_('first')); for ($i = 0, $n = count($orders); $i < $n; $i++) { if (JString::strlen($orders[$i]->text) > $chop) { $text = JString::substr($orders[$i]->text, 0, $chop) . "..."; } else { $text = $orders[$i]->text; } $order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value . ' (' . $text . ')'); } $order[] = JHTML::_('select.option', $orders[$i - 1]->value + 1, $orders[$i - 1]->value + 1 . ' ' . JText::_('last')); return $order; }
public function __construct(&$subject, $config) { parent::__construct($subject, $config); // Ensure that constructor is called one time self::$cookie = SID == ''; if (!self::$default_lang) { $app = JFactory::getApplication(); $router = $app->getRouter(); if ($app->isSite()) { // setup language data self::$mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false; self::$sefs = JLanguageHelper::getLanguages('sef'); self::$lang_codes = JLanguageHelper::getLanguages('lang_code'); self::$default_lang = JComponentHelper::getParams('com_languages')->get('site', 'en-GB'); self::$default_sef = self::$lang_codes[self::$default_lang]->sef; $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); foreach (self::$sefs as $sef => &$language) { if (isset($language->access) && $language->access && !in_array($language->access, $levels)) { unset(self::$sefs[$sef]); } } $app->setLanguageFilter(true); jimport('joomla.environment.uri'); $uri = JURI::getInstance(); if (self::$mode_sef) { // Get the route path from the request. $path = JString::substr($uri->toString(), JString::strlen($uri->base())); // Apache mod_rewrite is Off $path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10); // Trim any spaces or slashes from the ends of the path and explode into segments. $path = JString::trim($path, '/ '); $parts = explode('/', $path); // The language segment is always at the beginning of the route path if it exists. $sef = $uri->getVar('lang'); if (!empty($parts) && empty($sef)) { $sef = reset($parts); } } else { $sef = $uri->getVar('lang'); } if (isset(self::$sefs[$sef])) { $lang_code = self::$sefs[$sef]->lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain); $app->input->cookie->set(JApplication::getHash('language'), $lang_code); // set the request var $app->input->set('language', $lang_code); } } parent::__construct($subject, $config); // Detect browser feature if ($app->isSite()) { $app->setDetectBrowser($this->params->get('detect_browser', '1') == '1'); } } }
/** * Validates the username. * * @since 1.0 * @access public * @param null * @return JSON A jsong encoded string. * * @author Jason Rey <*****@*****.**> */ public function isValid() { // Render the ajax lib. $ajax = FD::getInstance('Ajax'); // Get the userid $userid = JRequest::getInt('userid', 0); // Get the event $event = JRequest::getString('event'); // Set the current username $current = ''; if (!empty($userid)) { $user = FD::user($userid); $current = $user->username; } // Get the provided username that the user has typed. $username = JRequest::getVar('username', ''); // Username is required, check if username is empty if (JString::strlen($username) < $this->params->get('min')) { return $ajax->reject(JText::sprintf('PLG_FIELDS_JOOMLA_USERNAME_MIN_CHARACTERS', $this->params->get('min'))); } // Test if username is allowed (by pass for adminedit). if ($event !== 'onAdminEdit' && !SocialFieldsUserJoomlaUsernameHelper::allowed($username, $this->params)) { return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_NOT_ALLOWED')); } // Test if username exists. if (SocialFieldsUserJoomlaUsernameHelper::exists($username, $current)) { return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_NOT_AVAILABLE')); } // Test if the username is valid if (!SocialFieldsUserJoomlaUsernameHelper::isValid($username, $this->params)) { return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_IS_INVALID')); } $text = JText::_('PLG_FIELDS_JOOMLA_USERNAME_AVAILABLE'); return $ajax->resolve($text); }
/** * Sanitize a value * * @param mixed Value to be sanitized * @return string */ protected function _sanitize($value) { $value = parent::_sanitize($value); $search_ignore = array(); // Limit term to 20 characters if (JString::strlen($value) > 20) { $value = JString::substr($value, 0, 19); } // Term must contain a minimum of 3 characters if ($value && JString::strlen($value) < 3) { $value = ''; } //Filter out search terms that are too small $words = explode(' ', JString::strtolower($value)); foreach ($words as $word) { if (JString::strlen($word) < 3) { $search_ignore[] = $word; } } if (count($words) > 1) { $pruned = array_diff($words, $search_ignore); $value = implode(' ', $pruned); } return $value; }
/** * Returns an array of options * * @param string $sql SQL with ordering As value and 'name field' AS text * @param integer $chop The length of the truncated headline * * @return array An array of objects formatted for JHtml list processing * @since 11.1 */ public static function genericordering($sql, $chop = '30') { $db = JFactory::getDbo(); $options = array(); $db->setQuery($sql); $items = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseNotice(500, $db->getErrorMsg()); return false; } if (empty($items)) { $options[] = JHtml::_('select.option', 1, JText::_('JOPTION_ORDER_FIRST')); return $options; } $options[] = JHtml::_('select.option', 0, '0 ' . JText::_('JOPTION_ORDER_FIRST')); for ($i = 0, $n = count($items); $i < $n; $i++) { $items[$i]->text = JText::_($items[$i]->text); if (JString::strlen($items[$i]->text) > $chop) { $text = JString::substr($items[$i]->text, 0, $chop) . "..."; } else { $text = $items[$i]->text; } $options[] = JHtml::_('select.option', $items[$i]->value, $items[$i]->value . '. ' . $text); } $options[] = JHtml::_('select.option', $items[$i - 1]->value + 1, $items[$i - 1]->value + 1 . ' ' . JText::_('JOPTION_ORDER_LAST')); return $options; }
function listDirectories($path, $regex = '.', $recurse = false) { $dirs = array(); // Make sure path is valid jimport('joomla.filesystem.path'); $path = JPath::clean($path); $root = strlen(JPATH_ROOT) ? JPATH_ROOT : DS; if (empty($path) || JString::strpos($path, $root) !== 0) { return $dirs; } // Find folders jimport('joomla.filesystem.folder'); $list = JFolder::folders($path, $regex, $recurse, true); if (empty($list)) { return $dirs; } // Create list of directories and the names foreach ($list as $path) { //$folder = JString::str_ireplace(JPATH_ROOT, '', $path); $folder = JString::substr($path, JString::strlen($root)); $folder = substr(str_replace(DS, '/', $folder), 1); $name = @explode('/', $folder); $name = array_pop($name); $dirs[] = array('folder' => $folder, 'name' => $name, 'path' => $path, 'path.64' => base64_encode($path)); } return $dirs; }
function DefaultViewEventCatRowNew($view, $row, $args = "") { // I choost not to use $row->fgcolor() $fgcolor = "inherit"; $router = JRouter::getInstance("site"); $vars = $router->getVars(); $vars["catids"] = $row->catid(); if (array_key_exists("Itemid", $vars) && is_null($vars["Itemid"])) { $vars["Itemid"] = JRequest::getInt("Itemid", 0); } $eventlink = "index.php?"; foreach ($vars as $key => $val) { $eventlink .= $key . "=" . $val . "&"; } $eventlink = JString::substr($eventlink, 0, JString::strlen($eventlink) - 1); $eventlink = JRoute::_($eventlink); ?> <a class="ev_link_cat" href="<?php echo $eventlink; ?> " style="color:<?php echo $fgcolor; ?> ;" title="<?php echo JEventsHTML::special($row->catname()); ?> "><?php echo $row->catname(); ?> </a> <?php }
public function execute($item) { $model = FD::model('comments'); $users = $model->getParticipants($item->uid, $item->context_type); $users[] = $item->actor_id; $users = array_values(array_unique(array_diff($users, array(FD::user()->id)))); $names = FD::string()->namesToNotifications($users); $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR'; $content = ''; if (count($users) == 1 && !empty($item->content)) { $content = JString::substr(strip_tags($item->content), 0, 30); if (JString::strlen($item->content) > 30) { $content .= JText::_('COM_EASYSOCIAL_ELLIPSES'); } } $item->content = $content; list($element, $group, $verb) = explode('.', $item->context_type); $streamItem = FD::table('streamitem'); $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid)); if (!$state) { return; } $owner = $streamItem->actor_id; if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) { $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_YOUR_ITEM' . $plurality, $names); return $item; } if ($item->actor_id == $owner && count($users) == 1) { $item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_COMMENTED_ON_ITEM' . FD::user($owner)->getGenderLang(), $names); return $item; } $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_USER_ITEM' . $plurality, $names, FD::user($owner)->getName()); return $item; }
function cutText($text, $limit_value, $limit_type, $at_end) { // solved problem from: https://www.gavick.com/support/forums/47/12309.html?p=57464#p57464 $cck_path = JPATH_BASE . DS . 'components' . DS . 'com_cck'; if (file_exists($cck_path)) { if (JComponentHelper::isEnabled('com_cck', true)) { // Force parsing plugin if SEBLOD is used if ($this->config['parse_plugins'] == FALSE) { $text = JHtml::_('content.prepare', $text); } $text = trim(substr(strip_tags($text, "<br /><br><strong></strong><p></p><i></i><b></b><span></span><ul></ul><li></li><blockquote></blockquote>"), 0)); } } if ($limit_type == 'words' && $limit_value > 0) { $temp = explode(' ', $text); if (count($temp) > $limit_value) { for ($i = 0; $i < $limit_value; $i++) { $cutted[$i] = $temp[$i]; } $cutted = implode(' ', $cutted); $text = $cutted . $at_end; } } elseif ($limit_type == 'words' && $limit_value == 0) { return ''; } else { if (JString::strlen($text) > $limit_value) { $text = JString::substr($text, 0, $limit_value) . $at_end; } } // replace unnecessary entities at end of the cutted text $toReplace = array('&&', '&a&', '&am&', '&&', '&q&', '&qu&', '&quo&', '"&', '&ap&', '&apo&', '&apos&'); $text = str_replace($toReplace, '&', $text); // return $text; }
/** * Outputs the html code for Twitter button * * @since 4.0 * @access public * @param string * @return */ public function html() { if (!$this->isEnabled()) { return; } $this->addScript(); // Get the pinterest button style from the configuration $size = $this->getButtonSize(); $url = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->post->id, false, true); // Combine the introtext and the content $content = $this->post->intro . $this->post->content; // Get the media $media = $this->getMedia(); $contentLength = 350; $text = $this->post->intro . $this->post->content; $text = nl2br($text); $text = strip_tags($text); $text = trim(preg_replace('/\\s+/', ' ', $text)); $text = JString::strlen($text) > $contentLength ? JString::substr($text, 0, $contentLength) . '...' : $text; $title = $this->post->title; // Urlencode all the necessary properties. $url = urlencode($url); $text = urlencode($text); $media = urlencode($media); $placeholder = $this->getPlaceholderId(); $theme = EB::template(); $theme->set('size', $size); $theme->set('placeholder', $placeholder); $theme->set('url', $url); $theme->set('title', $title); $theme->set('media', $media); $theme->set('text', $text); $output = $theme->output('site/socialbuttons/pinterest'); return $output; }
public function onAfterReply($message) { if (JString::strlen($message->message) > $this->params->get('activity_points_limit', 0)) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('com_kunena.thread.reply'); } $content = KunenaHtmlParser::plainBBCode($message->message, $this->params->get('activity_stream_limit', 0)); // Add readmore permalink $content .= '<br /><a rel="nofollow" href="' . $message->getTopic()->getPermaUrl() . '" class="small profile-newsfeed-item-action">' . JText::_('COM_KUNENA_READMORE') . '</a>'; $act = new stdClass(); $act->cmd = 'wall.write'; $act->actor = $message->userid; $act->target = 0; // no target $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>')); $act->content = $content; $act->app = 'kunena.post'; $act->cid = $message->thread; $act->access = $this->getAccess($message->getCategory()); // Comments and like support $act->comment_id = $message->thread; $act->comment_type = 'kunena.post'; $act->like_id = $message->thread; $act->like_type = 'kunena.post'; // Do not add private activities if ($act->access > 20) { return; } CFactory::load('libraries', 'activities'); CActivityStream::add($act); }
public static function getList($params) { $db = JFactory::getDBO(); $db->setQuery("SELECT * FROM #__jcomments ORDER BY date DESC", 0, $params->get('count')); $items = $db->loadObjectList(); if (!is_array($items)) { $items = array(); } if (count($items)) { $config = JCommentsFactory::getConfig(); $bbcode = JCommentsFactory::getBBCode(); $limit_comment_text = (int) $params->get('limit_comment_text', 0); foreach ($items as &$item) { $item->link = 'index.php?option=com_jcomments&&view=comment&layout=edit&id=' . $item->id; $item->author = JComments::getCommentAuthorName($item); $text = JCommentsText::censor($item->comment); $text = $bbcode->filter($text, true); $text = JCommentsText::cleanText($text); if ($limit_comment_text && JString::strlen($text) > $limit_comment_text) { $text = self::truncateText($text, $limit_comment_text - 1); } $item->comment = $text; } } return $items; }
/** * Get sub string (by words) * @param $text * @param $searchword * @return mixed|string */ public function smartSubstr($text, $searchword) { $length = self::MAX_LENGTH; $textlen = JString::strlen($text); $lsearchword = JString::strtolower($searchword); $wordfound = false; $pos = 0; $chunk = ''; while ($wordfound === false && $pos < $textlen) { if (($wordpos = @JString::strpos($text, ' ', $pos + $length)) !== false) { $chunk_size = $wordpos - $pos; } else { $chunk_size = $length; } $chunk = JString::substr($text, $pos, $chunk_size); $wordfound = JString::strpos(JString::strtolower($chunk), $lsearchword); if ($wordfound === false) { $pos += $chunk_size + 1; } } if ($wordfound !== false) { return ($pos > 0 ? '...' : '') . $chunk; } elseif (($wordpos = @JString::strpos($text, ' ', $length)) !== false) { return JString::substr($text, 0, $wordpos) . '...'; } else { return JString::substr($text, 0, $length); } }
public function getFieldHTML($field, $required) { $required = $field->required == 1 ? ' data-required="true"' : ''; //a fix for wrong data $field->value = JString::trim($field->value); if (JString::strrpos($field->value, ',') == JString::strlen($field->value) - 1) { $field->value = JString::substr($field->value, 0, -1); } $lists = explode(',', $field->value); //CFactory::load( 'helpers' , 'string' ); $html = '<select id="field' . $field->id . '" name="field' . $field->id . '[]" type="select-multiple" multiple="multiple" class="joms-select joms-select--multiple" title="' . CStringHelper::escape(JText::_($field->tips)) . '" ' . $required . '>'; $elementSelected = 0; foreach ($field->options as $option) { $selected = in_array($option, $lists) ? ' selected="selected"' : ''; if (empty($selected)) { $elementSelected++; } $html .= '<option value="' . $option . '"' . $selected . '>' . JText::_($option) . '</option>'; } if ($elementSelected == 0) { //if nothing is selected, we default the 1st option to be selected. $elementName = 'field' . $field->id; $html .= <<<HTML <script type='text/javascript'> var slt = document.getElementById('{$elementName}'); if(slt != null){ slt.options[0].selected = true; } </script> HTML; } $html .= '</select>'; return $html; }
protected function prepareGroupField() { $basetype = isset($this->element['basetype']) ? $this->element['basetype'] : 'text'; $basetype = (string) $basetype; $first_char = JString::substr($this->element['name'], 0, 1); $last_char = JString::substr($this->element['name'], JString::strlen($this->element['name']) - 1, 1); if ($basetype == 'group') { //If start or end of group if ($first_char == "{") { // Починаю нову групу (може бути будь-якого рівня вкладеності) $GLOBALS['variablefield']['output'] = false; $GLOBALS['variablefield']['current_group'][] = (string) $this->element['name'] . '}'; // Lower in the code I know, that last element of array $GLOBALS['variablefield']['current_group'] is always the current group. $this->groupstate = 'start'; $GLOBALS['variablefield']['fields'][] = clone $this; // I must clone } else { if ($last_char == "}") { $this->groupstate = 'end'; $GLOBALS['variablefield']['fields'][] = clone $this; array_pop($GLOBALS['variablefield']['current_group']); if (empty($GLOBALS['variablefield']['current_group'])) { $GLOBALS['variablefield']['output'] = true; } } } } else { if (!empty($GLOBALS['variablefield']['current_group'])) { // If in element from inside the group $this->groupstate = 'continue'; $this->defaultvalue = $this->value; $GLOBALS['variablefield']['fields'][] = clone $this; } } }
public function execute($item, $calendar) { $model = FD::model('comments'); $users = $model->getParticipants($item->uid, $item->context_type); // Include the notification actor $users[] = $item->actor_id; // Exclude the current user $users = array_values(array_unique(array_diff($users, array(FD::user()->id)))); $names = FD::string()->namesToNotifications($users); $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR'; $content = ''; if (count($users) == 1 && !empty($item->content)) { $content = JString::substr(strip_tags($item->content), 0, 30); if (JString::strlen($item->content) > 30) { $content .= JText::_('COM_EASYSOCIAL_ELLIPSES'); } } $item->content = $content; if ($calendar->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) { $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_YOUR_EVENT' . $plurality, $names); return $item; } if ($calendar->user_id == $item->actor_id && count($users) == 1) { $item->title = JText::sprintf('APP_USER_CALENDAR_OWNER_COMMENTED_ON_EVENT' . FD::user($calendar->user_id)->getGendarLang(), $names); return $item; } $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_USER_EVENT' . $plurality, $names, FD::user($calendar->user_id)->getName()); return $item; }
function fetchElement($name, $value, &$node, $control_name) { $size = $node->attributes('size') ? 'size="' . $node->attributes('size') . '"' : ''; $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="text_area"'; if (empty($value) && !is_array($value)) { $value = array('', '=', ''); } $html = ''; $db =& JFactory::getDBO(); $db->setQuery('SELECT cf_id AS value, caption AS text FROM #__mt_customfields WHERE published = 1 AND iscore = 0'); $customfields[] = JHTML::_('select.option', '', JText::_('- Select a field -')); $customfields = array_merge($customfields, $db->loadObjectList()); // trim long caption $i = 0; foreach ($customfields as $customfield) { if (JString::strlen($customfields[$i]->text) > $this->_max_caption_length - 3) { $customfields[$i]->text = JString::substr($customfields[$i]->text, 0, $this->_max_caption_length - 3) . '...'; } $i++; } $html .= JHTML::_('select.genericlist', $customfields, $control_name . '[' . $name . '][]', 'class="inputbox"', 'value', 'text', $value[0], $control_name . $name); $operators[] = JHTML::_('select.option', '=', JText::_('is equal to')); $operators[] = JHTML::_('select.option', '!=', JText::_('is not equal to')); $operators[] = JHTML::_('select.option', '>', JText::_('is more than')); $operators[] = JHTML::_('select.option', '<', JText::_('is less than')); $html .= JHTML::_('select.genericlist', $operators, $control_name . '[' . $name . '][]', 'class="inputbox"', 'value', 'text', $value[1], $control_name . $name); $html .= '<input type="text" name="' . $control_name . '[' . $name . '][]" id="' . $control_name . $name . '" value="' . $value[2] . '" ' . $class . ' ' . $size . ' />'; return $html; }
/** * Get the icon filename for a specific filename (or mime type) * * @param string $filename the filename to check * @param string $mime_type the MIME type to check (if the filename fails) * * @return the icon filename (or '' if none is found) */ public static function icon_filename($filename, $mime_type) { // Recognize some special cases first if ($mime_type == 'link/unknown' or $mime_type == 'unknown') { return 'link.gif'; } if ($mime_type == 'link/broken') { return 'link_bad.gif'; } if ($filename) { // Make sure it is a real filename if (strpos($filename, '.') === false) { // Do not know any better, assume it is text return 'text/plain'; } $path_info = pathinfo($filename); // Try the extension first $extension = JString::strtolower($path_info['extension']); if (array_key_exists($extension, AttachmentsFileTypes::$attachments_icon_from_file_extension)) { $iconf = AttachmentsFileTypes::$attachments_icon_from_file_extension[$extension]; if (JString::strlen($iconf) > 0) { return $iconf; } } } else { // Try the mime type if (array_key_exists($mime_type, AttachmentsFileTypes::$attachments_icon_from_mime_type)) { $iconf = AttachmentsFileTypes::$attachments_icon_from_mime_type[$mime_type]; if ($iconf && JString::strlen($iconf) > 0) { return $iconf; } } } return ''; }
public function display($tpl = null) { $model = KFactory::get('admin::com.nooku.model.articles'); $nooku = KFactory::get('admin::com.nooku.model.nooku'); $article = $model->getArticle(); $id = $model->getState('id'); if (JString::strlen($article->fulltext) > 1) { $text = $article->introtext . "<hr id=\"system-readmore\" />" . $article->fulltext; } else { $text = $article->introtext; } // for the lang switcher $languages = $nooku->getLanguages(); $target_lang = $languages[$nooku->getLanguage()]; $source_lang = $nooku->getPrimaryLanguage(); $source_url = 'index.php?option=com_nooku&view=translate.source&tmpl=component&id=' . $id . '&source_lang=' . $source_lang->iso_code; // Assign to template $this->assign('text', $text); $this->assign('languages', $languages); $this->assign('target_lang', $target_lang); $this->assign('source_lang', $source_lang); $this->assign('source_url', $source_url); $this->assign('id', $id); // Display the layout parent::display($tpl); }
function fetchElement($name, $value, &$node, $control_name) { $db =& JFactory::getDBO(); $db->setQuery('SELECT * FROM #__mt_customfields WHERE published = 1'); $fields = $db->loadObjectList(); if (!is_array($value)) { $value = array($value); } $html = ''; foreach ($fields as $field) { $html .= '<div style="width:125px;float:left;padding: 4px 3px"><input type="checkbox"'; $html .= ' name="' . $control_name . '[' . $name . '][]' . '"'; $html .= ' id="' . $control_name . $name . $field->cf_id . '"'; $html .= ' value="' . $field->cf_id . '"'; if (in_array($field->cf_id, $value)) { $html .= ' checked'; } $html .= ' />'; $field->caption = stripslashes($field->caption); $html .= ' <label for="' . $control_name . $name . $field->cf_id . '" title="' . $field->caption . '">'; if (JString::strlen($field->caption) > $this->_max_caption_length - 3) { $html .= JString::substr($field->caption, 0, $this->_max_caption_length - 3); $html .= '...'; } else { $html .= $field->caption; } $html .= '</label>'; $html .= '</div>'; } return $html; }
function links($rows, $team) { ?> <ul class="eblog_entry_links_list"> <?php for ($i = 1; $i < count($rows); $i++) { ?> <?php $item = $rows[$i]; ?> <li> <a href="<?php echo EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $item->id); ?> "> <?php echo JString::strlen($item->title) > 30 ? JString::substr(strip_tags($item->title), 0, 30) . '...' : strip_tags($item->title); ?> </a> <span><?php echo JString::strlen($item->content) > 100 ? JString::substr(strip_tags($item->content), 0, 100) . '...' : strip_tags($item->content); ?> </span> </li> <?php } //end for ?> </ul> <?php }
function wordDelete($string, $length, $end) { if (JString::strlen($string) < $length || JString::strlen($string) == $length) { return $string; } else { return JString::substr($string, 0, $length) . $end; } }
/** * @throws AppException */ public function index() { $this->app->jbdebug->mark('autocomplete::start'); if (!$this->app->jbcache->start(null, 'autocomplete')) { $type = $this->_jbrequest->get('type'); $query = $this->_jbrequest->get('value'); $appId = $this->_jbrequest->get('app_id'); $element = $this->_jbrequest->get('name'); if ($element && preg_match('/(?:\\[)([^]]*)(?:[]])(?(?<=\\[)|\\[?([^]]*))/i', $element, $element_id)) { $param_id = isset($element_id[2]) ? $element_id[2] : null; $element_id = $element_id[1]; $element = $this->app->jbentity->getElement($element_id, $type, $appId); $elementType = $element->getElementType(); $db = JBModelAutocomplete::model(); if ($element_id == '_itemname') { $rows = $db->name($query, $type, $appId); } elseif ($element_id == '_itemtag') { $rows = $db->tag($query, $type, $appId); } elseif ($element_id == '_itemauthor') { $rows = $db->author($query, $type, $appId); } else { if ($element instanceof ElementJBPrice) { $param_id = JBModelSku::model()->getId($param_id); $rows = $db->priceElement($query, $element_id, $param_id, $type, $appId); } else { if ($elementType == 'textarea') { $rows = $db->textarea($query, $element_id, $type, $appId); } else { if ($elementType == 'jbcomments') { $rows = $db->comments($query, $type, $appId); } else { $rows = $db->field($query, $element_id, $type, $appId); } } } } $data = array(); if (!empty($rows)) { foreach ($rows as $row) { if (JString::strlen($row->value) > self::MAX_LENGTH) { $value = $this->app->jbstring->smartSubstr($row->value, $query); } else { $value = $row->value; } $label = isset($row->label) ? $row->label : $row->value; $id = isset($row->id) ? $row->id : $row->value; $data[] = array('id' => JString::str_ireplace("\n", " ", $id), 'label' => JString::str_ireplace("\n", " ", $label), 'value' => JString::str_ireplace("\n", " ", JString::trim($value, '.'))); } } echo json_encode($data); } else { throw new AppException('Unkown element name'); } $this->app->jbcache->stop(); } $this->app->jbdebug->mark('autocomplete::end'); jexit(); }
function parseText($txt, $len=0) { if (!$txt) return; if ($len && JString::strlen($txt) > $len) $txt = JString::substr ( $txt, 0, $len ) . ' ...'; $txt = self::escape ( $txt ); $txt = preg_replace('/(\S{30})/u', '\1​', $txt); $txt = self::prepareContent ( $txt ); return $txt; }
public function onAfterReply($message) { if (JString::strlen($message->message) > $this->params->get('activity_points_limit', 0)) { CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('com_kunena.thread.reply'); } // Get users who have subscribed to the topic, excluding current user. $acl = KunenaAccess::getInstance(); $subscribers = $acl->getSubscribers($message->catid, $message->thread, KunenaAccess::TOPIC_SUBSCRIPTION, false, false, array($message->userid)); foreach ($subscribers as $userid) { $actor = CFactory::getUser($message->userid); $target = CFactory::getUser($userid); $params = new CParameter(''); $params->set('actorName', $actor->getDisplayName()); $params->set('recipientName', $target->getDisplayName()); $params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null)); // {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification $params->set('title', $message->displayField('subject')); // (title) tag in language file $params->set('title_url', $message->getPermaUrl()); // Make the title in notification - linkable $params->set('message', $message->displayField('message')); // (message) tag in language file $params->set('actor', $actor->getDisplayName()); // Actor in the stream $params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id); // Actor Link // Finally, send notifications CNotificationLibrary::add('kunena_reply', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TEXT'), '', $params); } /* Activity stream */ $act = new stdClass(); $act->cmd = 'wall.write'; $act->actor = $message->userid; $act->target = 0; // no target $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>')); $act->content = $this->buildContent($message); $act->app = 'kunena.thread.reply'; $act->cid = $message->thread; $act->access = $this->getAccess($message->getCategory()); // Comments and like support $act->comment_id = $message->thread; $act->comment_type = 'kunena.thread.reply'; $act->like_id = $message->thread; $act->like_type = 'kunena.thread.reply'; // Do not add private activities if ($act->access > 20) { return; } CFactory::load('libraries', 'activities'); $table = CActivityStream::add($act); if (is_object($table)) { $table->like_id = $table->id; $table->store(); } }
public static function wordDeleteWhole($string, $length, $end = '...') { if (JString::strlen($string) < $length || JString::strlen($string) == $length) { return $string; } else { preg_match('/(.{' . $length . '}.*?)\\b/', $string, $matches); return rtrim($matches[1]) . $end; } }
/** * */ public function display($cachable = false, $urlparams = false) { if ($_POST) { $params = JRequest::getVar('params'); $user = JXFactory::getUser(); $mainframe = JFactory::getApplication(); $emailChange = false; if ($user->email != $params['email']) { $emailChange = true; $oldEmail = $user->email; } // Only process this if there is an email change if ($emailChange) { $dummy = new JXUser(); $loadUser = $dummy->loadUserByEmail($params['email']); // Email is being used by another user; if ($loadUser === true && $dummy->id != $user->id) { $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_EMAIL_USED'), 'error'); return false; } else { // update invitation in case there are invitations from the previous email JModel::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'models'); $usersInvite = JModel::getInstance('usersInvite', 'AccountModel'); $usersInvite->updateFromEmail($oldEmail, $params['email'], $user); } } $params['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW); $params['password2'] = JRequest::getVar('confirm_password', '', 'post', 'string', JREQUEST_ALLOWRAW); // do a password safety check if (JString::strlen($params['password']) || JString::strlen($params['password2'])) { // so that "0" can be used as password e.g. if ($params['password'] != $params['password2']) { $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_REGISTER_ERRMSG_PASSWORD_MISMATCH'), 'error'); return false; } } $user->set('name', $params['name']); $user->set('email', $params['email']); $user->setParam('language', $params['language']); $user->setParam('about_me', $params['about_me']); $user->setParam('timezone', $params['timezone']); $user->setParam('style', $params['style']); $user->bind($params); if ($user->save()) { $percentageFilled = $user->getCalculateCompletion(); $user->setGettingStartedCompletion(JXUser::GSTARTED_COMPLETE_PROFILE, $percentageFilled); // Reload the user session $user->reloadSession(); /* Redirect to clear the previous user values */ $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_SAVE_PROFILE_SUCCESS')); } else { $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_SAVE_PROFILE_FAILED'), 'error'); } } parent::display(null); }
function _import($data = '') { if (!is_string($data) || JString::strlen($data) < 10 || JString::strpos($data, 'Bookmarks//Linkr') !== 0) { $this->setError(JText::_('INVALID_CSV')); return false; } $data = explode("\r\n", $data); if (JString::strpos($data[1], 'name') !== 0) { $this->setError(JText::_('INVALID_CSV')); return false; } elseif (!isset($data[2]) || strlen($data[2]) < 5) { $this->setError(JText::_('INVALID_CSV')); return false; } // Get current bookmarks $this->_db->setQuery('SELECT name FROM #__linkr_bookmarks'); $names = (array) $this->_db->loadResultArray(); $names = empty($names) ? array(JText::_('NONE')) : $names; // Get new bookmarks $new = array(); $amount = 0; for ($i = 2, $n = count($data); $i < $n; $i++) { $as = $this->_getAttributes($data[$i]); $bm = $this->_removeQuotes($as); if (!in_array($bm[0], $names)) { $new[] = $bm; $amount++; } } if (empty($new)) { $this->setError(JText::_('NO_BMS')); return false; } // Add new bookmarks $query = 'INSERT INTO #__linkr_bookmarks %1$s VALUES %2$s'; $cols = explode(',', $data[1]); foreach ($cols as $i => $c) { $cols[$i] = $this->_db->nameQuote($c); } $bms = array(); foreach ($new as $b) { $bm = array(); foreach ($b as $z) { $bm[] = is_numeric($z) ? (int) $z : $this->_db->Quote(htmlspecialchars_decode($z, ENT_COMPAT)); } $bms[] = implode(',', $bm); } $this->_db->setQuery(sprintf($query, '(' . implode(',', $cols) . ')', '(' . implode('),(', $bms) . ')')); $this->_db->query(); if ($this->_db->getErrorNum()) { $this->setError($this->_db->stderr()); return false; } return $amount; }