Example #1
0
 protected function getInput()
 {
     $db = JFactory::getDBO();
     $query = "SELECT * FROM #__k2_categories WHERE trash = 0 ORDER BY parent, ordering";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $children = array();
     if ($rows) {
         foreach ($rows as $row) {
             $row->title = $row->name;
             $row->parent_id = $row->parent;
             $pt = $row->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $row);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $rows = array();
     $rows[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'));
     foreach ($list as $item) {
         $item->treename = JString::str_ireplace(' ', ' -', $item->treename);
         $rows[] = JHTML::_('select.option', $item->id, $item->treename);
     }
     return JHTML::_('select.genericlist', $rows, $this->name, '', 'value', 'text', $this->value);
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     $db = JFactory::getDBO();
     $query = 'SELECT m.* FROM #__k2_categories m WHERE trash = 0 ORDER BY parent, ordering';
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     $children = array();
     if ($mitems) {
         foreach ($mitems as $v) {
             if (K2_JVERSION != '15') {
                 $v->title = $v->name;
                 $v->parent_id = $v->parent;
             }
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $mitems = array();
     foreach ($list as $item) {
         $item->treename = JString::str_ireplace(' ', '- ', $item->treename);
         @($mitems[] = JHTML::_('select.option', $item->id, $item->treename));
     }
     if (K2_JVERSION != '15') {
         $fieldName = $name;
     } else {
         $fieldName = $control_name . '[' . $name . ']';
     }
     return JHTML::_('select.genericlist', $mitems, $fieldName, ' class="inputbox" size="15"', 'value', 'text', $value);
 }
Example #3
0
 public function onAfterRender()
 {
     $fbml = '<html xmlns:fb="http://ogp.me/ns/fb#" ';
     $html = JResponse::getBody();
     $html = JString::str_ireplace('<html', $fbml, $html);
     JResponse::setBody($html);
 }
Example #4
0
 public static function replace($tmp, $text)
 {
     $config = DiscussHelper::getConfig();
     $pattern = '@(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))@';
     preg_match_all($pattern, $tmp, $matches);
     $targetBlank = $config->get('main_link_new_window') ? ' target="_blank"' : '';
     if (!isset($matches[0]) || !is_array($matches[0])) {
         return;
     }
     // to avoid infinite loop, unique the matches
     $links = $matches[0];
     foreach ($links as &$link) {
         $link = JString::strtolower($link);
     }
     $uniques = array_unique($links);
     foreach ($uniques as $match) {
         $matchProtocol = $match;
         if (stristr($matchProtocol, 'http://') === false && stristr($matchProtocol, 'https://') === false && stristr($matchProtocol, 'ftp://') === false) {
             $matchProtocol = 'http://' . $matchProtocol;
         }
         $text = JString::str_ireplace($match, '<a href="' . $matchProtocol . '"' . $targetBlank . '>' . $match . '</a>', $text);
     }
     $text = JString::str_ireplace('&quot;', '"', $text);
     return $text;
 }
Example #5
0
function stripExtensions($title)
{
    // Remove known extensions from title
    $extensions = array('jpg', 'png', 'gif');
    $title = JString::str_ireplace($extensions, '', $title);
    return $title;
}
Example #6
0
 /**
  * Unwrap placeholder text from possible <p> tags
  *
  * @param   array $match preg matched {fabrik} tag
  *
  * @return  string
  */
 protected function preplace($match)
 {
     $match = $match[0];
     $match = JString::str_ireplace('<p>', '<div>', $match);
     $match = JString::str_ireplace('</p>', '</div>', $match);
     return $match;
 }
Example #7
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $db =& JFactory::getDBO();
     $query = 'SELECT m.* FROM #__k2_categories m WHERE published=1 AND trash = 0 ORDER BY parent, ordering';
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     $fieldName = $name . '[]';
     if (count($mitems)) {
         $children = array();
         if ($mitems) {
             foreach ($mitems as $v) {
                 $v->title = $v->name;
                 $v->parent_id = $v->parent;
                 $pt = $v->parent;
                 $list = @$children[$pt] ? $children[$pt] : array();
                 array_push($list, $v);
                 $children[$pt] = $list;
             }
         }
         $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
         $mitems = array();
         foreach ($list as $item) {
             $item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
             $mitems[] = JHTML::_('select.option', $item->id, '   ' . $item->treename);
         }
         $output = JHTML::_('select.genericlist', $mitems, $fieldName, 'class="inputbox" multiple="multiple" size="10"', 'value', 'text', $value);
     } else {
         $mitems[] = JHTML::_('select.option', 0, 'K2 is not installed or there is no K2 category available.');
         $output = JHtml::_('select.genericlist', $mitems, $fieldName, 'class="inputbox" disabled="disabled" multiple="multiple" style="width:160px" size="5"', 'value', 'text', $value);
     }
     return $output;
 }
Example #8
0
 protected function getInput()
 {
     $output = '';
     if (!file_exists(JPATH_SITE . '/components/com_k2/helpers/utilities.php')) {
         $output .= JHTML::_('select.genericlist', array(), $this->name, 'class="inputbox" style="display:none" multiple="multiple" size="10"', 'value', 'text', $this->value, $this->id);
         $output .= JText::_('<p>Please install com_k2</p>');
         return $output;
     }
     $db = JFactory::getDBO();
     $query = 'SELECT m.* FROM #__k2_categories m WHERE trash = 0 ORDER BY parent, ordering';
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     $children = array();
     if ($mitems) {
         foreach ($mitems as $v) {
             $v->title = $v->name;
             $v->parent_id = $v->parent;
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $mitems = array();
     foreach ($list as $item) {
         $item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
         $mitems[] = JHTML::_('select.option', $item->id, '   ' . $item->treename);
     }
     $output = JHTML::_('select.genericlist', $mitems, $this->name, 'class="inputbox" multiple="multiple" size="10"', 'value', 'text', $this->value, $this->id);
     return $output;
 }
Example #9
0
 function store()
 {
     $table =& $this->getTable();
     $post = JRequest::get('post');
     // Fix HTML
     $post['htmltext'] = JRequest::getString('htmltext', '', 'post', JREQUEST_ALLOWRAW);
     $post['htmltext'] = JString::str_ireplace('&amp;amp;', '&amp;', $post['htmltext']);
     $post['htmlsmall'] = JRequest::getString('htmlsmall', '', 'post', JREQUEST_ALLOWRAW);
     $post['htmlsmall'] = JString::str_ireplace('&amp;amp;', '&amp;', $post['htmlsmall']);
     $post['htmllarge'] = JRequest::getString('htmllarge', '', 'post', JREQUEST_ALLOWRAW);
     $post['htmllarge'] = JString::str_ireplace('&amp;amp;', '&amp;', $post['htmllarge']);
     $post['htmlbutton'] = JRequest::getString('htmlbutton', '', 'post', JREQUEST_ALLOWRAW);
     $post['htmlbutton'] = JString::str_ireplace('&amp;amp;', '&amp;', $post['htmlbutton']);
     $post['htmlcustom'] = JRequest::getString('htmlcustom', '', 'post', JREQUEST_ALLOWRAW);
     $post['htmlcustom'] = JString::str_ireplace('&amp;amp;', '&amp;', $post['htmlcustom']);
     // Bind form data to table fields
     if (!$table->bind($post)) {
         $this->setError($table->getError());
         return false;
     }
     // Make sure the record is a valid one
     if (!$table->check()) {
         $this->setError($table->getError());
         return false;
     }
     // Save bookmark
     if (!$table->store()) {
         $this->setError($table->getError());
         return false;
     }
     return $table->get('id');
 }
Example #10
0
 function onProfileCreate($user)
 {
     // Upon registering, users should get 4 default photo albums:
     // Fiskeplasser, Fangstrapporter, Turer, and Klekker (Spots/Catches/Trips/Hatches)
     $config = CFactory::getConfig();
     CFactory::load('models', 'photos');
     $albumNames = array('Fiskeplasser', 'Fangstrapporter', 'Turer', 'Klekker');
     foreach ($albumNames as $album_name) {
         $album =& JTable::getInstance('Album', 'CTable');
         $album->creator = $user->id;
         $album->name = $album_name;
         $album->description = "";
         $album->type = "user";
         $album->created = gmdate('Y-m-d H:i:s');
         $params = $user->getParams();
         $album->permissions = $params->get('privacyPhotoView');
         $album->permanent = 1;
         // don't let users delete default albums
         $storage = JPATH_ROOT . DS . $config->getString('photofolder');
         $albumPath = $storage . DS . 'photos' . DS . $user->id . DS;
         $albumPath = JString::str_ireplace(JPATH_ROOT . DS, '', $albumPath);
         $albumPath = JString::str_ireplace('\\', '/', $albumPath);
         $album->path = $albumPath;
         $album->store();
     }
 }
Example #11
0
 public function check()
 {
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_JUDOWNLOAD_TITLE_MUST_NOT_BE_EMPTY'));
         return false;
     }
     if (trim($this->alias) == '') {
         $this->alias = $this->title;
     }
     $this->alias = JApplication::stringURLSafe($this->alias);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
     }
     if (trim(str_replace('&nbsp;', '', $this->description)) == '') {
         $this->description = '';
     }
     if (!empty($this->metakeyword)) {
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         $after_clean = JString::str_ireplace($bad_characters, "", $this->metakeyword);
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             if (trim($key)) {
                 $clean_keys[] = trim($key);
             }
         }
         $this->metakeyword = implode(", ", $clean_keys);
     }
     return true;
 }
Example #12
0
	public static function ejaxPostToArray($params)
	{
		$post		= array();

		foreach($params as $item)
		{
			$pair   = explode('=', $item);

			if( isset( $pair[ 0 ] ) && isset( $pair[ 1 ] ) )
			{
				$key	= $pair[0];
				$value	= KomentoStringHelper::ejaxUrlDecode( $pair[ 1 ] );

				if( JString::stristr( $key , '[]' ) !== false )
				{
					$key			= JString::str_ireplace( '[]' , '' , $key );
					$post[ $key ][]	= $value;
				}
				else
				{
					$post[ $key ] = $value;
				}
			}
		}

		return $post;
	}
Example #13
0
 public function setImage($path, $type = 'thumb')
 {
     CError::assert($path, '', '!empty', __FILE__, __LINE__);
     $db =& $this->getDBO();
     // Fix the back quotes
     $path = JString::str_ireplace('\\', '/', $path);
     $type = JString::strtolower($type);
     // Test if the record exists.
     $oldFile = $this->{$type};
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     if ($oldFile) {
         // File exists, try to remove old files first.
         $oldFile = JString::str_ireplace('/', DS, $oldFile);
         // If old file is default_thumb or default, we should not remove it.
         // Need proper way to test it
         if (!JString::stristr($oldFile, 'user.png') && !JString::stristr($oldFile, 'user_thumb.png')) {
             jimport('joomla.filesystem.file');
             JFile::delete($oldFile);
         }
     }
     $this->{$type} = $path;
     $this->store();
 }
Example #14
0
 /**
  * Do a batch send
  */
 function send($total = 100)
 {
     $mailqModel = CFactory::getModel('mailq');
     $userModel = CFactory::getModel('user');
     $mails = $mailqModel->get($total);
     $jconfig = JFactory::getConfig();
     $mailer = JFactory::getMailer();
     $config = CFactory::getConfig();
     $senderEmail = $jconfig->getValue('mailfrom');
     $senderName = $jconfig->getValue('fromname');
     if (empty($mails)) {
         return;
     }
     CFactory::load('helpers', 'string');
     foreach ($mails as $row) {
         // @rule: only send emails that is valid.
         // @rule: make sure recipient is not blocked!
         $userid = $userModel->getUserFromEmail($row->recipient);
         $user = CFactory::getUser($userid);
         if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
             $mailer->setSender(array($senderEmail, $senderName));
             $mailer->addRecipient($row->recipient);
             $mailer->setSubject($row->subject);
             $tmpl = new CTemplate();
             $raw = isset($row->params) ? $row->params : '';
             $params = new JParameter($row->params);
             $base = $config->get('htmlemail') ? 'email.html' : 'email.text';
             if ($config->get('htmlemail')) {
                 $row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
                 $mailer->IsHTML(true);
             } else {
                 //@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
                 $row->body = CStringHelper::escape(strip_tags($row->body));
             }
             $tmpl->set('content', $row->body);
             $tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
             $tmpl->set('sitename', $config->get('sitename'));
             $row->body = $tmpl->fetch($base);
             // Replace any occurences of custom variables within the braces scoe { }
             if (!empty($row->body)) {
                 preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
                 foreach ($matches as $val) {
                     $replaceWith = $params->get($val[1], null);
                     //if the replacement start with 'index.php', we can CRoute it
                     if (strpos($replaceWith, 'index.php') === 0) {
                         $replaceWith = CRoute::getExternalURL($replaceWith);
                     }
                     if (!is_null($replaceWith)) {
                         $row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
                     }
                 }
             }
             unset($tmpl);
             $mailer->setBody($row->body);
             $mailer->send();
         }
         $mailqModel->markSent($row->id);
         $mailer->ClearAllRecipients();
     }
 }
Example #15
0
    public static function getCategoryOptionsPerLanguage($config = array('filter.published' => array(0, 1), 'filter.languages' => array()))
    {

        $hash = md5(serialize($config));

        if (!isset(self::$_categoriesOptionsPerLanguage[$hash]))
        {

            $config = (array)$config;

            // read categories from db
            $items = self::getCategoriesPerLanguage($config);

            // B/C compat.
            foreach ($items as &$item)
            {
                $item->title = $item->name;
                $item->parent_id = $item->parent;
            }

            // indent cat list, for easier reading
            $items = self::indentCategories($items);

            self::$_categoriesOptionsPerLanguage[$hash] = array();
            foreach ($items as &$item)
            {
                self::$_categoriesOptionsPerLanguage[$hash][] = JHtml::_('select.option', $item->id, JString::str_ireplace('<sup>|_</sup>', '', $item->treename));
            }

        }

        return self::$_categoriesOptionsPerLanguage[$hash];
    }
Example #16
0
 function edit($id, $tpl = 'edit')
 {
     // For JomSocial 2.x.x to Getting js Constant.
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'defines.community.php';
     $params = $this->getModel()->loadParams($id);
     $lists = array();
     for ($i = 1; $i <= 31; $i++) {
         $qscale[] = JHTML::_('select.option', $i, $i);
     }
     $lists['qscale'] = JHTML::_('select.genericlist', $qscale, 'qscale', 'class="inputbox" size="1"', 'value', 'text', $params->get('qscale', '11'));
     $videosSize = array(JHTML::_('select.option', '320x240', '320x240 (QVGA 4:3)'), JHTML::_('select.option', '400x240', '400x240 (WQVGA 5:3)'), JHTML::_('select.option', '400x300', '400x300 (Quarter SVGA 4:3)'), JHTML::_('select.option', '480x272', '480x272 (Sony PSP 30:17)'), JHTML::_('select.option', '480x320', '480x320 (iPhone 3:2)'), JHTML::_('select.option', '512x384', '512x384 (4:3)'), JHTML::_('select.option', '600x480', '600x480 (5:4)'), JHTML::_('select.option', '640x360', '640x360 (16:9)'), JHTML::_('select.option', '640x480', '640x480 (VCA 4:3)'), JHTML::_('select.option', '800x600', '800x600 (SVGA 4:3)'));
     $lists['videosSize'] = JHTML::_('select.genericlist', $videosSize, 'videosSize', 'class="inputbox" size="1"', 'value', 'text', $params->get('videosSize'));
     // FOR JomSocial 2.1
     //Add image quality in view file for JS Configuration page error
     $imgQuality = array(JHTML::_('select.option', '60', 'Low'), JHTML::_('select.option', '80', 'Medium'), JHTML::_('select.option', '90', 'High'), JHTML::_('select.option', '95', 'Very High'));
     $lists['imgQuality'] = JHTML::_('select.genericlist', $imgQuality, 'output_image_quality', 'class="inputbox" size="1"', 'value', 'text', $params->get('output_image_quality'));
     $uploadLimit = ini_get('upload_max_filesize');
     $uploadLimit = JString::str_ireplace('M', ' MB', $uploadLimit);
     // Group discussion order option
     $groupDiscussionOrder = array(JHTML::_('select.option', 'ASC', 'Older first'), JHTML::_('select.option', 'DESC', 'Newer first'));
     $lists['groupDicussOrder'] = JHTML::_('select.genericlist', $groupDiscussionOrder, 'group_discuss_order', 'class="inputbox" size="1"', 'value', 'text', $params->get('group_discuss_order'));
     $this->assign('lists', $lists);
     $this->assign('uploadLimit', $uploadLimit);
     $this->assign('config', $params);
     $this->assign('id', $id);
     $this->assign('jsConfigPath', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'views' . DS . 'configuration' . DS . 'tmpl');
     $this->setToolBar();
     // Set the titlebar text
     return parent::display($tpl);
 }
 function getInput()
 {
     $params = JComponentHelper::getParams('com_k2');
     $db = JFactory::getDBO();
     $query = 'SELECT m.* FROM #__k2_categories m WHERE published=1 AND trash = 0 ORDER BY parent, ordering';
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     $children = array();
     if ($mitems) {
         foreach ($mitems as $v) {
             $v->title = $v->name;
             $v->parent_id = $v->parent;
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $attr = 'class="inputbox chzn-select"';
     $attr .= 'style="width:280px;"';
     $attr .= 'multiple="multiple"';
     $attr .= 'data-placeholder="Click here to select categories"';
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $mitems = array();
     foreach ($list as $item) {
         $item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
         $mitems[] = JHTML::_('select.option', $item->id, '   ' . $item->treename);
     }
     $fieldName = $this->name . '[]';
     $output = JHTML::_('select.genericlist', $mitems, $fieldName, trim($attr), 'value', 'text', $this->value);
     return $output;
 }
Example #18
0
 function onAfterRender()
 {
     $fbml = '<html xmlns:fb="http://www.facebook.com/2008/fbml"';
     $html = JResponse::getBody();
     $html = JString::str_ireplace('<html', $fbml, $html);
     JResponse::setBody($html);
 }
Example #19
0
 function display($data = null)
 {
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     $document =& JFactory::getDocument();
     $document->setTitle(JText::sprintf('CC FRONTPAGE TITLE', $config->get('sitename')));
     $document->setLink(CRoute::_('index.php?option=com_community'));
     $my = CFactory::getUser();
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'string');
     $act = new CActivityStream();
     $rows = $act->getFEED('', '', null, $mainframe->getCfg('feed_limit'));
     if ($config->get('showactivitystream') == COMMUNITY_SHOW || $config->get('showactivitystream') == COMMUNITY_MEMBERS_ONLY && $my->id != 0) {
         foreach ($rows->data as $row) {
             if ($row->type != 'title') {
                 // load individual item creator class
                 $item = new JFeedItem();
                 // cannot escape the title. it's already formated. we should
                 // escape it during CActivityStream::add
                 //$item->title 		= CStringHelper::escape($row->title);
                 $item->title = $row->title;
                 $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->actor);
                 $item->description = "<img src=\"{$row->favicon}\" alt=\"\"/>&nbsp;" . $row->title;
                 $item->date = $row->createdDate;
                 $item->category = '';
                 //$row->category;
                 // Make sure url is absolute
                 $item->description = JString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
                 // loads item info into rss array
                 $document->addItem($item);
             }
         }
     }
 }
Example #20
0
 public function store($updateNulls = false)
 {
     if (isset($this->alias)) {
         $this->alias = JApplication::stringURLSafe($this->alias);
     }
     if (!empty($this->metakey)) {
         // Only process if not empty
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         // array of characters to remove
         $after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
         // remove bad characters
         $keys = explode(',', $after_clean);
         // create array using commas as delimiter
         $clean_keys = array();
         foreach ($keys as $key) {
             if (trim($key)) {
                 // Ignore blank keywords
                 $clean_keys[] = trim($key);
             }
         }
         $this->metakey = implode(", ", $clean_keys);
         // put array back together delimited by ", "
     }
     if (empty($this->answer_created_by_id)) {
         $this->answer_created_by_id = JFactory::getUser()->id;
     }
     return parent::store($updateNulls);
 }
Example #21
0
 function authorizeAccess()
 {
     $mainframe = JFactory::getApplication();
     $session = JFactory::getSession();
     $config = DiscussHelper::getConfig();
     $consumerKey = $config->get('integration_twitter_consumer_key');
     $consumerSecretKey = $config->get('integration_twitter_consumer_secret_key');
     if ($session->has('twitter_oauth_request_token', 'discuss')) {
         //$request_token		= $session->get('twitter_oauth_token', 'discuss');
         $session_request = JString::str_ireplace(',', "\r\n", $session->get('twitter_oauth_request_token', '', 'discuss'));
         $request_token = DiscussHelper::getRegistry($session_request);
         /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
         $connection = new DiscussTwitterOAuth($consumerKey, $consumerSecretKey, $request_token->get('oauth_token', ''), $request_token->get('oauth_token_secret', ''));
         /* Request access tokens from twitter */
         $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
         if (!empty($access_token['oauth_token']) && !empty($access_token['oauth_token_secret'])) {
             if ($session->has('twitter_oauth_access_token', 'discuss')) {
                 $session->clear('twitter_oauth_access_token', 'discuss');
             }
             $session->set('twitter_oauth_access_token', "user_id=" . $access_token["user_id"] . ",screen_name=" . $access_token["screen_name"] . ",oauth_token=" . $access_token['oauth_token'] . ",oauth_token_secret=" . $access_token['oauth_token_secret'], 'discuss');
             $status = true;
             $msg = JText::_('COM_EASYDISCUSS_TWITTER_OAUTH_SUCCESS');
         } else {
             $status = false;
             $msg = JText::_('COM_EASYDISCUSS_TWITTER_OAUTH_FAILED');
         }
     } else {
         $status = false;
         $msg = JText::_('COM_EASYDISCUSS_TWITTER_USER_NOT_FOUND');
     }
     echo "<script language=javascript>window.opener.discuss.login.twitter.signin(" . $status . ", '" . $msg . "'); self.close();</script>";
 }
 /**
  * Method to convert a string into underscore separated form.
  *
  * @param   string  $input  The string input.
  *
  * @return  string  The underscore separated string.
  *
  * @since   11.3
  */
 public static function toUnderscoreSeparated($input)
 {
     // Convert spaces and dashes to underscores.
     $input = JString::str_ireplace(array(' ', '-'), '_', $input);
     // Remove duplicate underscores.
     $input = preg_replace('#_+#', '_', $input);
     return $input;
 }
Example #23
0
 /**
  * @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();
 }
Example #24
0
 /**
  * Fixes oembed links
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return	
  */
 public function fixOembedLinks($oembed)
 {
     // Fix video issues with youtube when site is on https
     if (isset($oembed->provider_url) && $oembed->provider_url == 'http://www.youtube.com/') {
         $oembed->html = JString::str_ireplace('http://', 'https://', $oembed->html);
         $oembed->thumbnail = str_ireplace('http://', 'https://', $oembed->thumbnail);
     }
     return $oembed;
 }
Example #25
0
 /**
  * Add sharing sites into bookmarks
  * @params	string	$providerName	Pass the provider name to be displayed
  * @params	string	$imageURL	 	 Image that needs to be displayed beside the provider
  * @params	string	$apiURL			Api URL that JomSocial should link to	 
  **/
 function add($providerName, $className, $apiURL)
 {
     $apiURL = JString::str_ireplace('{uri}', $this->currentURI, $apiURL);
     $obj = new stdClass();
     $obj->name = $providerName;
     $obj->className = $className;
     $obj->link = $apiURL;
     $this->_bookmarks[JString::strtolower($providerName)] = $obj;
 }
Example #26
0
 public static function getInstallerObject($version)
 {
     $filename = JPATH_ADMINISTRATOR . DS . "components" . DS . "com_jvrelatives" . DS . "setup" . DS . $version . ".php";
     if (!JFile::exists($filename)) {
         throw new Exception("Installer PHP file [" . $filename . "] does not exist");
     }
     require_once $filename;
     $clsname = "JvrelVersionInstaller_" . JString::str_ireplace(".", "_", $version);
     return new $clsname($version);
 }
Example #27
0
 /**
  * Overrides parent store function as we need to clean up some variables
  **/
 public function store()
 {
     if (!$this->check()) {
         return false;
     }
     $this->image = JString::str_ireplace('\\', '/', $this->image);
     $this->thumbnail = JString::str_ireplace('\\', '/', $this->thumbnail);
     $this->original = JString::str_ireplace('\\', '/', $this->original);
     return parent::store();
 }
Example #28
0
 public function store($updateNulls = false)
 {
     if (empty($this->value) && !empty($this->title)) {
         $this->value = JString::strtolower(JString::str_ireplace(' ', '', $this->title));
     }
     if (empty($this->title) && !empty($this->value)) {
         $this->title = JString::ucfirst($this->value);
     }
     return parent::store($updateNulls);
 }
Example #29
0
 function listFiles($path, $regex = '.')
 {
     $files = array();
     // Make sure path is valid
     $path = JPath::clean($path);
     if (empty($path) || JString::strpos($path, JPATH_ROOT) === false) {
         return $files;
     }
     $list = JFolder::files($path, $regex, false, true);
     if (empty($list)) {
         return $files;
     }
     foreach ($list as $filename) {
         $f = new JObject();
         $f->name = JFile::getName($filename);
         $f->path = $filename;
         $f->src = JString::str_ireplace(JPATH_ROOT . DS, JURI::root(), $f->path);
         $f->src = str_replace(DS, '/', $f->src);
         $f->size = LinkrHelper::parseSize($f->path);
         $f->ext = strtolower(JFile::getExt($f->name));
         switch ($f->ext) {
             // Image
             case 'bmp':
             case 'gif':
             case 'jpg':
             case 'jpeg':
             case 'odg':
             case 'png':
             case 'xcf':
                 list($w, $h) = @getimagesize($f->path);
                 $size = LinkrHelper::imageResize($w, $h, 32);
                 $f->width = $size['width'];
                 $f->height = $size['height'];
                 $f->icon = JString::str_ireplace(JPATH_ROOT . DS, JURI::root(), $f->path);
                 $f->icon = str_replace(DS, '/', $f->icon);
                 $f->type = JText::_('Image');
                 break;
                 // Other files
             // Other files
             default:
                 $f->type = strtoupper($f->ext);
                 $f->width = 32;
                 $f->height = 32;
                 $icon = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_media' . DS . 'images' . DS . 'mime-icon-32' . DS . $f->ext . '.png';
                 if (file_exists($icon)) {
                     $f->icon = JURI::root() . 'administrator/components/com_media/images/mime-icon-32/' . $f->ext . '.png';
                 } else {
                     $f->icon = JURI::root() . 'administrator/components/com_media/images/con_info.png';
                 }
                 break;
         }
         $files[] = $f;
     }
     return $files;
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     $params =& JComponentHelper::getParams('com_k2');
     $document =& JFactory::getDocument();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         JHtml::_('behavior.framework');
     } else {
         JHTML::_('behavior.mootools');
     }
     $backendJQueryHandling = $params->get('backendJQueryHandling', 'remote');
     if ($backendJQueryHandling == 'remote') {
         $document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js');
         //$document->addScript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js');
     } else {
         $document->addScript(JURI::root(true) . '/media/k2/assets/js/jquery-1.7.1.min.js');
         //$document->addScript(JURI::root(true).'/media/k2/assets/js/jquery-ui-1.8.16.custom.min.js');
     }
     $db =& JFactory::getDBO();
     $query = 'SELECT m.* FROM #__k2_categories m WHERE published=1 AND trash = 0 ORDER BY parent, ordering';
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     $children = array();
     if ($mitems) {
         foreach ($mitems as $v) {
             if (K2_JVERSION == '16') {
                 $v->title = $v->name;
                 $v->parent_id = $v->parent;
             }
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $mitems = array();
     foreach ($list as $item) {
         $item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
         $mitems[] = JHTML::_('select.option', $item->id, '   ' . $item->treename);
     }
     $doc =& JFactory::getDocument();
     if (K2_JVERSION == '16') {
         $js = "\n\t\t\tvar \$K2 = jQuery.noConflict();\n\t\t\t\$K2(document).ready(function(){\n\t\t\t\t\n\t\t\t\t\$K2('#jform_params_catfilter0').click(function(){\n\t\t\t\t\t\$K2('#jformparamscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#jformparamscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\t\$K2('#jform_params_catfilter1').click(function(){\n\t\t\t\t\t\$K2('#jformparamscategory_id').removeAttr('disabled');\n\t\t\t\t\t\$K2('#jformparamscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).removeAttr('selected');\n\t\t\t\t\t});\n\t\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tif (\$K2('#jform_params_catfilter0').attr('checked')) {\n\t\t\t\t\t\$K2('#jformparamscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#jformparamscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (\$K2('#jform_params_catfilter1').attr('checked')) {\n\t\t\t\t\t\$K2('#jformparamscategory_id').removeAttr('disabled');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\t";
     } else {
         $js = "\n\t\t\tvar \$K2 = jQuery.noConflict();\n\t\t\t\$K2(document).ready(function(){\n\t\t\t\t\n\t\t\t\t\$K2('#paramscatfilter0').click(function(){\n\t\t\t\t\t\$K2('#paramscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#paramscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\t\$K2('#paramscatfilter1').click(function(){\n\t\t\t\t\t\$K2('#paramscategory_id').removeAttr('disabled');\n\t\t\t\t\t\$K2('#paramscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).removeAttr('selected');\n\t\t\t\t\t});\n\t\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tif (\$K2('#paramscatfilter0').attr('checked')) {\n\t\t\t\t\t\$K2('#paramscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#paramscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (\$K2('#paramscatfilter1').attr('checked')) {\n\t\t\t\t\t\$K2('#paramscategory_id').removeAttr('disabled');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\t";
     }
     if (K2_JVERSION == '16') {
         $fieldName = $name . '[]';
     } else {
         $fieldName = $control_name . '[' . $name . '][]';
     }
     $doc->addScriptDeclaration($js);
     $output = JHTML::_('select.genericlist', $mitems, $fieldName, 'class="inputbox" style="width:90%;" multiple="multiple" size="10"', 'value', 'text', $value);
     return $output;
 }