/** * replace flag * * @access private * @param $article object the article object * @return boolean */ function _replace_player($article) { $ereg = '/{saudioplayer(\\s+autostart)?}(.+\\.mp3){\\/saudioplayer}/iU'; if (preg_match_all($ereg, $article->text, $matches, PREG_SET_ORDER)) { //get plugin parameters $default_folder = $this->params->get('default_folder'); $default_width = $this->params->get('default_width'); $default_height = $this->params->get('default_height'); $default_background_color = $this->params->get('default_background_color'); //replace flag static $loop_count = 1; foreach ($matches as $match) { if (preg_match('/^http:\\/\\/.+\\/.+\\.mp3$/i', $match[2])) { $mp3_file = $match[2]; } else { $mp3_file = JURI::base() . $default_folder . '/' . $match[2]; } $player_file = JURI::base() . 'plugins/content/saudioplayer/player/niftyplayer/niftyplayer.swf'; if ($match[1]) { $auto_start = '&as=1'; } else { $auto_start = ''; } $play_code = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' . $default_width . '" height="' . $default_height . '" id="niftyPlayer' . $loop_count . '"> <param name="movie" value="' . $player_file . '?file=' . $mp3_file . $auto_start . '" /> <param name="quality" value="high" /> <param name="bgcolor" value="' . $default_background_color . '" /> <embed src="' . $player_file . '?file=' . $mp3_file . $auto_start; $play_code .= '" quality="high" bgcolor="' . $default_background_color . '" width="' . $default_width . '" height="' . $default_height . '" name="niftyPlayer' . $loop_count . '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed> </object>'; $flag_pos = JString::strpos($article->text, $match[0]); $article->text = JString::substr_replace($article->text, $play_code, $flag_pos, JString::strlen($match[0])); $loop_count++; } return true; } else { return false; } }
/** * Method to convert a string into variable form. * * @param string $input The string input. * * @return string The variable string. * * @since 11.3 */ public static function toVariable($input) { // Remove dashes and underscores, then convert to camel case. $input = self::toSpaceSeparated($input); $input = self::toCamelCase($input); // Remove leading digits. $input = preg_replace('#^[0-9]+.*$#', '', $input); // Lowercase the first character. $first = JString::substr($input, 0, 1); $first = JString::strtolower($first); // Replace the first character with the lowercase character. $input = JString::substr_replace($input, $first, 0, 1); return $input; }
/** * Returns the mention form * * @since 1.2 * @access public * @param string * @return */ public function getMentionsForm($resetToDefault = false) { $theme = FD::themes(); $tmp = array(); $this->overlay = $this->content; if ($this->mentions) { // Store mentions temporarily to avoid escaping $i = 0; foreach ($this->mentions as $mention) { if ($mention->utype == 'user') { $user = FD::user($mention->uid); $replace = '<span data-value="user:'******'" data-type="entity">' . $user->getName() . '</span>'; } if ($mention->utype == 'hashtag') { $replace = '<span data-value="' . $mention->title . '" data-type="hashtag">' . "#" . $mention->title . '</span>'; } $tmp[$i] = $replace; $replace = '[si:mentions]' . $i . '[/si:mentions]'; $this->overlay = JString::substr_replace($this->overlay, $replace, $mention->offset, $mention->length); $i++; } } $this->overlay = FD::string()->escape($this->overlay); for ($x = 0; $x < count($tmp); $x++) { $this->overlay = str_ireplace('[si:mentions]' . $x . '[/si:mentions]', $tmp[$x], $this->overlay); } $theme->set('story', $this); $theme->set('defaultOverlay', $resetToDefault ? $story->overlay : ''); $theme->set('defaultContent', $resetToDefault ? $story->content : ''); $contents = $theme->output('site/mentions/form'); return $contents; }
/** * Processes mentions in a stream object * * @since 1.0 * @access public * @param string * @return */ public function formatMentions(SocialStreamItem &$stream) { // Get the current view $view = JRequest::getCmd('view', ''); // Get the stream's content $content = $stream->content; // Get tags for the stream $tags = isset($stream->tags) ? $stream->tags : array(); // If there is no tags, just skip this and escape the content if (!$tags) { return FD::string()->escape($content); } // We need to store the changes in an array and replace it accordingly based on the counter. $items = array(); // We need to merge the mentions and hashtags since we are based on the offset. $i = 0; foreach ($tags as $tag) { if ($tag->type == 'user') { $replace = '<a href="' . $tag->user->getPermalink() . '" data-popbox="module://easysocial/profile/popbox" data-popbox-position="top-left" data-user-id="' . $tag->user->id . '" class="mentions-user">' . $tag->user->getName() . '</a>'; } if ($tag->type == 'hashtag') { // $alias = JFilterOutput::stringURLSafe($tag->title); $alias = $tag->title; $url = ''; if ($view == 'groups') { $clusterReg = FD::registry($stream->params); $object = $clusterReg->get($stream->cluster_type); switch ($stream->cluster_type) { case SOCIAL_TYPE_GROUP: // for now we assume all is group type. $group = new SocialGroup(); $group->bind($object); $url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'tag' => $alias)); break; case SOCIAL_TYPE_EVENT: $event = new SocialEvent(); $event->bind($object); $url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'tag' => $alias)); break; default: FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias)); break; } } else { $url = FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias)); } $replace = '<a href="' . $url . '" class="mentions-hashtag">#' . $tag->title . '</a>'; } $links[$i] = $replace; $replace = '[si:mentions]' . $i . '[/si:mentions]'; $content = JString::substr_replace($content, $replace, $tag->offset, $tag->length); $i++; } // Once we have the content, escape it $content = FD::string()->escape($content); if ($links) { for ($x = 0; $x < count($links); $x++) { $content = str_ireplace('[si:mentions]' . $x . '[/si:mentions]', $links[$x], $content); } } return $content; }
/** * @group String * @covers JString::substr_replace * @dataProvider substr_replaceData */ public function testSubstr_replace($string, $replacement, $start, $length, $expect) { $actual = JString::substr_replace($string, $replacement, $start, $length); $this->assertEquals($expect, $actual); }
/** * Create the sql query to get the rows data for insertion into the form * * @param array $opts key: ignoreOrder ignores order by part of query * Needed for inline edit, as it only selects certain fields, order by on a db join element returns 0 results * * @return string query */ public function buildQuery($opts = array()) { if (isset($this->query)) { return $this->query; } $db = FabrikWorker::getDbo(); $input = $this->app->input; $form = $this->getForm(); if (!$form->record_in_database) { return; } $listModel = $this->getListModel(); $item = $listModel->getTable(); $sql = $listModel->buildQuerySelect('form'); $sql .= $listModel->buildQueryJoin(); $emptyRowId = $this->rowId === '' ? true : false; $random = $input->get('random'); $useKey = FabrikWorker::getMenuOrRequestVar('usekey', '', $this->isMambot, 'var'); if ($useKey != '') { $useKey = explode('|', $useKey); foreach ($useKey as &$tmpK) { $tmpK = !strstr($tmpK, '.') ? $item->db_table_name . '.' . $tmpK : $tmpK; $tmpK = FabrikString::safeColName($tmpK); } if (!is_array($this->rowId)) { $aRowIds = explode('|', $this->rowId); } } $comparison = $input->get('usekey_comparison', '='); $viewPk = $input->get('view_primary_key'); // $$$ hugh - changed this to !==, as in rowid=-1/usekey situations, we can have a rowid of 0 // I don't THINK this will have any untoward side effects, but ... if (!$random && !$emptyRowId || !empty($useKey)) { $sql .= ' WHERE '; if (!empty($useKey)) { $sql .= "("; $parts = array(); for ($k = 0; $k < count($useKey); $k++) { /** * * For gory reasons, we have to assume that an empty string cannot be a valid rowid * when using usekey, so just create a 1=-1 if it is. */ if ($aRowIds[$k] === '') { $parts[] = ' 1=-1'; continue; } // Ensure that the key value is not quoted as we Quote() afterwards if ($comparison == '=') { $parts[] = ' ' . $useKey[$k] . ' = ' . $db->q($aRowIds[$k]); } else { $parts[] = ' ' . $useKey[$k] . ' LIKE ' . $db->q('%' . $aRowIds[$k] . '%'); } } $sql .= implode(' AND ', $parts); $sql .= ')'; } else { $sql .= ' ' . $item->db_primary_key . ' = ' . $db->q($this->rowId); } } else { if ($viewPk != '') { $sql .= ' WHERE ' . $viewPk . ' '; } elseif ($random) { // $$$ rob Should this not go after prefilters have been applied ? $sql .= ' ORDER BY RAND() LIMIT 1 '; } } // Get pre-filter conditions from table and apply them to the record // the false, ignores any filters set by the table $where = $listModel->buildQueryWhere(false); if (strstr($sql, 'WHERE')) { // Do it this way as queries may contain sub-queries which we want to keep the where $firstWord = JString::substr($where, 0, 5); if ($firstWord == 'WHERE') { $where = JString::substr_replace($where, 'AND', 0, 5); } } // Set rowId to -2 to indicate random record if ($random) { $this->setRowId(-2); } // $$$ rob ensure that all prefilters are wrapped in brackets so that // only one record is loaded by the query - might need to set $word = and? if (trim($where) != '') { $where = explode(' ', $where); $word = array_shift($where); $sql .= $word . ' (' . implode(' ', $where) . ')'; } if (!$random && FArrayHelper::getValue($opts, 'ignoreOrder', false) === false) { // $$$ rob if showing joined repeat groups we want to be able to order them as defined in the table $sql .= $listModel->buildQueryOrder(); } $this->query = $sql; return $sql; }
/** * Convert string into css class name * * @param string $input string * * @return string */ protected function toVariable($input) { // Should simply be (except there's a bug in J) // JStringNormalise::toVariable($event->className); $input = trim($input); // Remove dashes and underscores, then convert to camel case. $input = JStringNormalise::toSpaceSeparated($input); $input = JStringNormalise::toCamelCase($input); // Remove leading digits. $input = preg_replace('#^[\\d\\.]*#', '', $input); // Lowercase the first character. $first = JString::substr($input, 0, 1); $first = JString::strtolower($first); // Replace the first character with the lowercase character. $input = JString::substr_replace($input, $first, 0, 1); return $input; }
/** * Processes a text and replace the mentions / hashtags hyperlinks. * * @since 1.2 * @access public * @param string * @return */ public function processTags($tags, $message, $simpleTags = false) { // We need to merge the mentions and hashtags since we are based on the offset. foreach ($tags as $tag) { if ($tag->type == 'entity' || $tag->type == 'user') { if (isset($tag->user) && $tag->user instanceof SocialUser) { $user = $tag->user; } else { $user = FD::user($tag->item_id); } if ($simpleTags) { $data = new stdClass(); $data->type = $tag->type; $data->link = $user->getPermalink(); $data->title = $user->getName(); $data->id = $user->id; $replace = '[tag]' . FD::json()->encode($data) . '[/tag]'; } else { $replace = '<a href="' . $user->getPermalink() . '" data-popbox="module://easysocial/profile/popbox" data-popbox-position="top-left" data-user-id="' . $user->id . '" class="mentions-user">' . $user->getName() . '</a>'; } } if ($tag->type == 'hashtag') { $alias = JFilterOutput::stringURLSafe($tag->title); $url = FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias)); if ($simpleTags) { $data = new stdClass(); $data->type = $tag->type; $data->link = $url; $data->title = $tag->title; $data->id = $tag->id; $replace = '[tag]' . FD::json()->encode($data) . '[/tag]'; } else { $replace = '<a href="' . $url . '" class="mentions-hashtag">#' . $tag->title . '</a>'; } } $message = JString::substr_replace($message, $replace, $tag->offset, $tag->length); } return $message; }
/** * Perform log * * @param string $messageType message type * * @return bool */ protected function log($messageType) { $params = $this->getParams(); $formModel = $this->getModel(); $input = $this->app->input; $db = FabrikWorker::getDBO(); $rowId = $input->get('rowid', '', 'string'); $loading = strstr($messageType, 'form.load'); $http_referrer = $input->server->get('HTTP_REFERER', 'no HTTP_REFERER', 'string'); $userId = $this->user->get('id'); $username = $this->user->get('username'); // Generate random filename if ($params->get('logs_random_filename') == 1) { $randomFileName = '_' . $this->generateFilename($params->get('logs_random_filename_length')); } else { $randomFileName = ''; } $w = new FabrikWorker(); $logsPath = $w->parseMessageForPlaceHolder($params->get('logs_path')); if (strpos($logsPath, '/') !== 0) { $logsPath = JPATH_ROOT . '/' . $logsPath; } $logsPath = rtrim($logsPath, '/'); if (!JFolder::exists($logsPath)) { if (!JFolder::create($logsPath)) { return; } } $ext = $params->get('logs_file_format'); $sep = $params->get('logs_separator'); // Making complete path + filename + extension $w = new FabrikWorker(); $logsFile = $logsPath . '/' . $w->parseMessageForPlaceHolder($params->get('logs_file')) . $randomFileName . '.' . $ext; $logsMode = $params->get('logs_append_or_overwrite'); $date_element = $params->get('logs_date_field'); $date_now = $params->get('logs_date_now'); // COMPARE DATA $result_compare = ''; if ($params->get('compare_data')) { if ($ext == 'csv') { $sep_compare = ''; $sep_2compare = '/ '; } elseif ($ext == 'txt') { $sep_compare = "\n"; $sep_2compare = "\n"; } elseif ($ext == 'htm') { $sep_compare = '<br/>'; $sep_2compare = '<br/>'; } if ($loading) { $result_compare = FText::_('COMPARE_DATA_LOADING') . $sep_2compare; } else { $data = $this->getProcessData(); $newData = $this->getNewData(); if (!empty($data)) { $filter = JFilterInput::getInstance(); $post = $filter->clean($_POST, 'array'); $tableModel = $formModel->getTable(); $origDataCount = count(array_keys(ArrayHelper::fromObject($formModel->_origData[0]))); if ($origDataCount > 0) { $c = 0; $origData = $formModel->_origData; $log_elements = $params->get('logs_element_list', ''); if (!empty($log_elements)) { $log_elements = explode(',', str_replace(' ', '', $log_elements)); } $groups = $formModel->getGroupsHiarachy(); foreach ($groups as $groupModel) { $group = $groupModel->getGroup(); $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $element = $elementModel->getElement(); $fullName = $elementModel->getFullName(true, false); if (empty($log_elements) || in_array($fullName, $log_elements)) { if ($newData[$c]->{$fullName} != $origData[$c]->{$fullName}) { $result_compare .= FText::_('COMPARE_DATA_CHANGE_ON') . ' ' . $element->label . ' ' . $sep_compare . FText::_('COMPARE_DATA_FROM') . ' ' . $origData[0]->{$fullName} . ' ' . $sep_compare . FText::_('COMPARE_DATA_TO') . ' ' . $newData[$c]->{$fullName} . ' ' . $sep_2compare; } } } } if (empty($result_compare)) { $result_compare = FText::_('COMPARE_DATA_NO_DIFFERENCES'); } } else { $result_compare .= "New record:" . $sep_2compare; foreach ($data as $key => $val) { if (isset($val) && substr($key, -4, 4) != '_raw') { $result_compare .= "{$key} : {$val}" . $sep_2compare; } } } } else { $result_compare = "No data to compare!"; } } } // Defining the date to use - Not used any more as logs should really only record the current time_date if ($date_now != '') { $date = date("{$date_now}"); } else { $date = date("Y-m-d H:i:s"); } // Custom Message if ($params->get('custom_msg') != '') { $rep_add_edit = $messageType == 'form.add' ? FText::_('REP_ADD') : ($messageType == 'form.edit' ? FText::_('REP_EDIT') : FText::_('DETAILS')); $custom_msg = $params->get('custom_msg'); $custom_msg = preg_replace('/{Add\\/Edit}/', $rep_add_edit, $custom_msg); $custom_msg = preg_replace('/{DATE}/', $date, $custom_msg); $excl_clabels = preg_replace('/([-{2}| |"][0-9a-zA-Z.:$_>]*)/', '', $custom_msg); $split_clabels = preg_split('/[+]{1,}/', $excl_clabels); $clabels = preg_replace('/[={2}]+[a-zA-Z0-9_-]*/', '', $split_clabels); $ctypes = preg_replace('/[a-zA-Z0-9_-]*[={2}]/', '', $split_clabels); $labtyp = array_combine($clabels, $ctypes); $w = new FabrikWorker(); $custom_msg = $w->parseMessageForPlaceHolder($custom_msg); $regex = '/((?!("[^"]*))([ |\\w|+|.])+(?=[^"]*"\\b)|(?!\\b"[^"]*)( +)+(?=([^"]*)$)|(?=\\b"[^"]*)( +)+(?=[^"]*"\\b))/'; $excl_cdata = preg_replace($regex, '', $custom_msg); $cdata = preg_split('/["]{1,}/', $excl_cdata); // Labels for CSV & for DB $clabels_csv_imp = implode("\",\"", $clabels); $clabels_csv_p1 = preg_replace('/^(",)/', '', $clabels_csv_imp); $clabels_csv = ''; $clabels_csv .= preg_replace('/(,")$/', '', $clabels_csv_p1); if ($params->get('compare_data') == 1) { $clabels_csv .= ', "' . FText::_('PLG_FORM_LOG_COMPARE_DATA_LABEL_CSV') . '"'; } $clabels_createdb_imp = ''; foreach ($labtyp as $klb => $vlb) { $klb = $db->qn($klb); if ($vlb == 'varchar') { $clabels_createdb_imp .= $klb . ' ' . $vlb . '(255) NOT NULL, '; } elseif ($vlb == 'int') { $clabels_createdb_imp .= $klb . ' ' . $vlb . '(11) NOT NULL, '; } elseif ($vlb == 'datetime') { $clabels_createdb_imp .= $klb . ' ' . $vlb . ' NOT NULL, '; } } $clabels_createdb = JString::substr_replace($clabels_createdb_imp, '', -2); if ($params->get('compare_data') == 1) { $clabels_createdb .= ', ' . $db->qn(FText::_('COMPARE_DATA_LABEL_DB')) . ' text NOT NULL'; } // @todo - what if we use different db driver which doesn't name quote with `?? $clabels_db_imp = implode("`,`", $clabels); $clabels_db_p1 = preg_replace('/^(`,)/', '', $clabels_db_imp); $clabels_db = preg_replace('/(,`)$/', '', $clabels_db_p1); if ($params->get('compare_data') == 1) { $clabels_db .= ', ' . $db->qn(FText::_('PLG_FORM_LOG_COMPARE_DATA_LABEL_DB')); } // Data for CSV & for DB $cdata_csv_imp = implode("\",\"", $cdata); $cdata_csv_p1 = preg_replace('/^(",)/', '', $cdata_csv_imp); $cdata_csv = preg_replace('/(,")$/', '', $cdata_csv_p1); $cdata_csv = preg_replace('/={1,}",/', '', $cdata_csv); $cdata_csv = preg_replace('/""/', '"', $cdata_csv); if ($params->get('compare_data') == 1) { $cdata_csv .= ', "' . $result_compare . '"'; } $cdata_db_imp = implode("','", $cdata); $cdata_db_p1 = preg_replace("/^(',)/", '', $cdata_db_imp); $cdata_db = preg_replace("/(,')\$/", '', $cdata_db_p1); $cdata_db = preg_replace("/={1,}',/", '', $cdata_db); $cdata_db = preg_replace("/''/", "'", $cdata_db); if ($params->get('compare_data') == 1 && !$loading) { $result_compare = preg_replace('/<br\\/>/', '- ', $result_compare); $result_compare = preg_replace('/\\n/', '- ', $result_compare); $cdata_db .= ", '" . $result_compare . "'"; } $custom_msg = preg_replace('/([++][0-9a-zA-Z.:_]*)/', '', $custom_msg); $custom_msg = preg_replace('/^[ ]/', '', $custom_msg); $custom_msg = preg_replace('/ /', ' ', $custom_msg); $custom_msg = preg_replace('/"/', '', $custom_msg); if ($params->get('compare_data') == 1 && !$loading) { $custom_msg .= '<br />' . $result_compare; } } else { $clabelsCreateDb = array(); $clabelsDb = array(); $cdataDb = array(); $clabelsCreateDb[] = $db->qn('date') . " datetime NOT NULL"; $clabelsDb[] = $db->qn('date'); $cdataDb[] = "NOW()"; $clabelsCreateDb[] = $db->qn('ip') . " varchar(32) NOT NULL"; $clabelsDb[] = $db->qn('ip'); $cdataDb[] = $params->get('logs_record_ip') == '1' ? $db->q(FabrikString::filteredIp()) : $db->q(''); $clabelsCreateDb[] = $db->qn('referer') . " varchar(255) NOT NULL"; $clabelsDb[] = $db->qn('referer'); $cdataDb[] = $params->get('logs_record_referer') == '1' ? $db->q($http_referrer) : $db->q(''); $clabelsCreateDb[] = $db->qn('user_agent') . " varchar(255) NOT NULL"; $clabelsDb[] = $db->qn('user_agent'); $cdataDb[] = $params->get('logs_record_useragent') == '1' ? $db->q($input->server->getString('HTTP_USER_AGENT')) : $db->q(''); $clabelsCreateDb[] = $db->qn('data_comparison') . " TEXT NOT NULL"; $clabelsDb[] = $db->qn('data_comparison'); $cdataDb[] = $params->get('compare_data') == '1' ? $db->q($result_compare) : $db->q(''); $clabelsCreateDb[] = $db->qn('rowid') . " INT(11) NOT NULL"; $clabelsDb[] = $db->qn('rowid'); $cdataDb[] = $db->q($rowId); $clabelsCreateDb[] = $db->qn('userid') . " INT(11) NOT NULL"; $clabelsDb[] = $db->qn('userid'); $cdataDb[] = $db->q((int) $userId); $clabelsCreateDb[] = $db->qn('tableid') . " INT(11) NOT NULL"; $clabelsDb[] = $db->qn('tableid'); $cdataDb[] = $db->q($formModel->getListModel()->getId()); $clabelsCreateDb[] = $db->qn('formid') . " INT(11) NOT NULL"; $clabelsDb[] = $db->qn('formid'); $cdataDb[] = $db->q($formModel->getId()); $clabels_createdb = implode(", ", $clabelsCreateDb); $clabels_db = implode(", ", $clabelsDb); $cdata_db = implode(", ", $cdataDb); } /* For CSV files * If 'Append' method is used, you don't want to repeat the labels (Date, IP, ...) * each time you add a line in the file */ $labels = !JFile::exists($logsFile) || $logsMode == 'w' ? 1 : 0; $buffer = $logsMode == 'a' && JFile::exists($logsFile) ? file_get_contents($logsFile) : ''; $send_email = $params->get('log_send_email') == '1'; $make_file = $params->get('make_file') == '1'; if ($send_email && !$make_file) { $ext = 'txt'; } $email_msg = ''; // @TODO redo all this with JFile API and only writing a string once - needless overhead doing fwrite all the time if ($make_file || $send_email) { // Opening or creating the file if ($params->get('custom_msg') != '') { if ($send_email) { $email_msg = $custom_msg; } if ($make_file) { $custMsg = $buffer; if ($ext != 'csv') { $thisMsg = $buffer . $custom_msg . "\n" . $sep . "\n"; JFile::write($logsFile, $thisMsg); } else { // Making the CSV file // If the file already exists, do not add the 'label line' if ($labels == 1) { $custMsg .= $clabels_csv; } // Inserting data in CSV with actual line break as row separator $custMsg .= "\n" . $cdata_csv; JFile::write($logsFile, $custMsg); } } } else { // Making HTM File if ($ext == 'htm') { $htmlMsg = "<b>Date:</b> " . $date . "<br/>"; if ($params->get('logs_record_ip') == 1) { $htmlMsg .= "<b>IP Address:</b> " . FabrikString::filteredIp() . "<br/>"; } if ($params->get('logs_record_referer') == 1) { $htmlMsg .= "<b>Referer:</b> " . $http_referrer . "<br/>"; } if ($params->get('logs_record_useragent') == 1) { $htmlMsg .= "<b>UserAgent: </b>" . $input->server->getString('HTTP_USER_AGENT') . "<br/>"; } $htmlMsg .= $result_compare . $sep . "<br/>"; if ($send_email) { $email_msg = $htmlMsg; } if ($make_file) { $htmlMsg = $buffer . $htmlMsg; $res = JFile::write($logsFile, $htmlMsg); if (!$res) { $this->app->enqueueMessage("error writing html to log file: " . $logsFile, 'notice'); } } } elseif ($ext == 'txt') { $txtMsg = "Date: " . $date . "\n"; $txtMsg .= "Form ID: " . $formModel->getId() . "\n"; $txtMsg .= "Table ID: " . $formModel->getListModel()->getId() . "\n"; $txtMsg .= "Row ID: " . $rowId . "\n"; $txtMsg .= "User ID: {$userId} ({$username})\n"; if ($params->get('logs_record_ip') == 1) { $txtMsg .= "IP Address: " . FabrikString::filteredIp() . "\n"; } if ($params->get('logs_record_referer') == 1) { $txtMsg .= "Referer: " . $http_referrer . "\n"; } if ($params->get('logs_record_useragent') == 1) { $txtMsg .= "UserAgent: " . $input->server->getString('HTTP_USER_AGENT') . "\n"; } $txtMsg .= $result_compare . $sep . "\n"; if ($send_email) { $email_msg = $txtMsg; } if ($make_file) { $txtMsg = $buffer . $txtMsg; JFile::write($logsFile, $txtMsg); } } elseif ($ext == 'csv') { // Making the CSV file $csvMsg = array(); // If the file already exists, do not add the 'label line' if ($labels == 1) { $csvMsg[] = "Date"; if ($params->get('logs_record_ip') == 1) { // Putting some "" around the label to avoid two different fields $csvMsg[] = "\"IP Address\""; } if ($params->get('logs_record_referer') == 1) { $csvMsg[] = "Referer"; } if ($params->get('logs_record_useragent') == 1) { $csvMsg[] = "UserAgent"; } if ($params->get('compare_data') == 1) { $csvMsg[] = "\"" . FText::_('COMPARE_DATA_LABEL_CSV') . "\""; } } // Inserting data in CSV with actual line break as row separator $csvMsg[] = "\n\"" . $date . "\""; if ($params->get('logs_record_ip') == 1) { $csvMsg[] = "\"" . FabrikString::filteredIp() . "\""; } if ($params->get('logs_record_referer') == 1) { $csvMsg[] = "\"" . $http_referrer . "\""; } if ($params->get('logs_record_useragent') == 1) { $csvMsg[] = "\"" . $input->server->getString('HTTP_USER_AGENT') . "\""; } if ($params->get('compare_data') == 1) { $csvMsg[] = "\"" . $result_compare . "\""; } $csvMsg = implode(",", $csvMsg); if ($send_email) { $email_msg = $csvMsg; } if ($make_file) { if ($buffer !== '') { $csvMsg = $buffer . $csvMsg; } JFile::write($logsFile, $csvMsg); } } } } if ($params->get('logs_record_in_db') == 1) { // In which table? if ($params->get('record_in') == '') { $rdb = '#__fabrik_log'; } else { $db_suff = $params->get('record_in'); $form = $formModel->getForm(); $fid = $form->id; $db->setQuery("SELECT " . $db->qn('db_table_name') . " FROM " . $db->qn('#__fabrik_lists') . " WHERE " . $db->qn('form_id') . " = " . (int) $fid); $tname = $db->loadResult(); $rdb = $db->qn($tname . $db_suff); } // Making the message to record if ($params->get('custom_msg') != '') { $message = preg_replace('/<br\\/>/', ' ', $custom_msg); } else { $message = $this->makeStandardMessage($result_compare); } /* $$$ hugh - FIXME - not sure about the option driven $create_custom_table stuff, as this won't work * if they add an option to an existing log table. We should probably just create all the optional columns * regardless. */ if ($params->get('record_in') == '') { $in_db = "INSERT INTO {$rdb} (" . $db->qn('referring_url') . ", " . $db->qn('message_type') . ", " . $db->qn('message') . ") VALUES (" . $db->q($http_referrer) . ", " . $db->q($messageType) . ", " . $db->q($message) . ");"; $db->setQuery($in_db); $db->execute(); } else { $create_custom_table = "CREATE TABLE IF NOT EXISTS {$rdb} (" . $db->qn('id') . " int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, {$clabels_createdb});"; $db->setQuery($create_custom_table); $db->execute(); $in_db = "INSERT INTO {$rdb} ({$clabels_db}) VALUES ({$cdata_db});"; $db->setQuery($in_db); if (!$db->execute()) { /* $$$ changed to always use db fields even if not selected * so logs already created may need optional fields added. * try adding every field we should have, don't care if query fails. */ foreach ($clabelsCreateDb as $insert) { $db->setQuery("ALTER TABLE ADD {$insert} AFTER `id`"); $db->execute(); } // ... and try the insert query again $db->setQuery($in_db); $db->execute(); } } } if ($send_email) { jimport('joomla.mail.helper'); $emailFrom = $this->config->get('mailfrom'); $emailTo = explode(',', $w->parseMessageForPlaceholder($params->get('log_send_email_to', ''))); $subject = strip_tags($w->parseMessageForPlaceholder($params->get('log_send_email_subject', 'log event'))); foreach ($emailTo as $email) { $email = trim($email); if (empty($email)) { continue; } if (FabrikWorker::isEmail($email)) { $mail = JFactory::getMailer(); $res = $mail->sendMail($emailFrom, $emailFrom, $email, $subject, $email_msg, true); } else { $app->enqueueMessage(JText::sprintf('DID_NOT_SEND_EMAIL_INVALID_ADDRESS', $email)); } } } return true; }
public function getEditComment() { $id = FD::input()->getInt('id'); $comment = FD::table('comments'); $comment->load($id); $tags = FD::model('Tags')->getTags($id, 'comments'); $overlay = $comment->comment; $counter = 0; $tmp = array(); foreach ($tags as $tag) { if ($tag->type === 'entity' && $tag->item_type === SOCIAL_TYPE_USER) { $user = FD::user($tag->item_id); $replace = '<span data-value="user:'******'" data-type="entity">' . $user->getName() . '</span>'; } if ($tag->type === 'hashtag') { $replace = '<span data-value="' . $tag->title . '" data-type="hashtag">' . "#" . $tag->title . '</span>'; } $tmp[$counter] = $replace; $replace = '[si:mentions]' . $counter . '[/si:mentions]'; $overlay = JString::substr_replace($overlay, $replace, $tag->offset, $tag->length); $counter++; } $overlay = FD::string()->escape($overlay); foreach ($tmp as $i => $v) { $overlay = str_ireplace('[si:mentions]' . $i . '[/si:mentions]', $v, $overlay); } $theme = FD::themes(); $theme->set('comment', $comment->comment); $theme->set('overlay', $overlay); $contents = $theme->output('site/comments/editForm'); $this->getCurrentView()->call(__FUNCTION__, $contents); }
protected function _doOutput(&$article, &$params, &$faqline) { $html = ""; $document = JFactory::getDocument(); if (!$this->_editParamNames($params, $html)) { return $this->_formattedError($html, $faqline); } $cssfile = "plugins/content/accordionfaq/css/accordionfaq.css"; $faqlinks = $params->get("faqlinks", ""); if (strtolower($faqlinks) == "space") { $faqlinks = " "; } if (!$this->_editParamValue("faqid", $params, "accordion1", $faqid, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editParamValue("faqclass", $params, "lightnessfaq defaulticon headerbackground headerborder contentbackground contentborder round5", $faqclass, $html)) { return $this->_formattedError($html, $faqline); } $header = $params->get("header", 'h3'); if (!$this->_editTrueFalse("autoheight", $params, "0", $autoheight, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editTrueFalse("autonumber", $params, "0", $autonumber, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editTrueFalse("alwaysopen", $params, "0", $alwaysopen, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editTrueFalse("openmultiple", $params, "0", $openmultiple, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editTrueFalse("scrollonopen", $params, "0", $scrollonopen, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editTrueFalse("warnings", $params, "1", $warnings, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editTrueFalse("usedynamiccssload", $params, "1", $usedynamiccssload, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editTrueFalse("keyaccess", $params, "1", $keyaccess, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editEvent("event", $params, "click", $event, $html)) { return $this->_formattedError($html, $faqline); } if (!$this->_editAnimation("animation", $params, "none", $animation, $html)) { return $this->_formattedError($html, $faqline); } $active = $params->get("active", ""); if (!$this->_editNumeric("scrolltime", $params, 1000, $scrolltime, $html)) { return $this->_formattedError($html, $faqline); } $scrolltime = max($scrolltime, 1); if (!$this->_editNumeric("scrolloffset", $params, 0, $scrolloffset, $html)) { return $this->_formattedError($html, $faqline); } $activearr[0] = "false"; $faqitem = JRequest::getString('faqitem', ''); if ($active != "" && $faqitem == "") { $activearr = explode(',', $active); for ($i = 0; $i < count($activearr); $i++) { $activearr[$i] = JString::trim($activearr[$i]); if (!is_numeric($activearr[$i])) { $activearr[$i] = "'#" . $activearr[$i] . "'"; } } } if ($faqitem != "") { $faqitems = explode(',', $faqitem); $i = 0; do { $faqitems[$i] = JString::trim($faqitems[$i]); if (JString::strpos($faqitems[$i], $faqid) === 0) { $faqitemtarget = JString::substr($faqitems[$i], JString::strlen($faqid)); if ($faqitemtarget != "") { if (is_numeric($faqitemtarget)) { $faqitemid = (int) $faqitemtarget; $activearr[$i] = $faqitemid; $jumpto = $faqitems[$i]; } else { $activearr[$i] = "'#" . $faqitemtarget . "'"; $jumpto = $faqitemtarget; } } else { $jumpto = $faqitem; } } $i++; } while (!isset($jumpto) && $i < count($faqitems)); } $printfaq = JRequest::getString("print", 'false'); if ($printfaq == "1") { if (isset($jumpto)) { unset($jumpto); } $animation = 'false'; $printfaq = 'true'; } else { $printfaq = 'false'; } $browser = JBrowser::getInstance(); $isIE6 = false; if ($browser->getBrowser() == "msie" && $browser->getMajor() <= 6) { $isIE6 = true; $ie6css = JPATH_BASE . DIRECTORY_SEPARATOR . $cssfile; $ie6css = JPath::clean($ie6css, DIRECTORY_SEPARATOR); if (JString::substr($ie6css, JString::strlen($ie6css) - 4, 4) == '.css') { $ie6css = JString::substr_replace($ie6css, '-ie6.css', JString::strlen($ie6css) - 4, 4); } if (JFile::exists($ie6css)) { $styledata = JFile::read($ie6css); $newtext = preg_replace("/src=( )*'( )*([^' ]+)'/i", "src='" . JURI::root(true) . "\\3" . "'", $styledata); $newtext = preg_replace("/url\\(( )*'( )*([^' ]+)'/i", "url('" . JURI::root(true) . "\\3" . "'", $newtext); $document->addStyleDeclaration($newtext); } } $document->addStyleSheet(JURI::root(true) . "/" . $cssfile); $cssbase = JPATH_BASE . DIRECTORY_SEPARATOR . $cssfile; $cssbase = JPath::clean($cssbase, DIRECTORY_SEPARATOR); $cssfilename = JFile::getName($cssbase); $cssbase = str_replace($cssfilename, '', $cssbase); $faqbase = str_replace($cssfilename, '', $cssfile); $faqclassarray = preg_split("/[\\s]+/", $faqclass); for ($i = 0; $i < count($faqclassarray); $i++) { if (preg_match("/(.*)faq\$/i", $faqclassarray[$i], $match)) { $faqfile = $cssbase . $faqclassarray[$i] . ".css"; if (JFile::exists($faqfile)) { if ($usedynamiccssload == 'tru') { $document->addStyleSheet(JURI::root(true) . "/" . $faqbase . "css.php?id=" . $faqid . "&faq=" . $faqclassarray[$i]); } else { $document->addStyleSheet(JURI::root(true) . "/" . $faqbase . $faqclassarray[$i] . ".css"); } if ($isIE6) { $ie6css = $cssbase . $faqclassarray[$i] . "-ie6.css"; if (JFile::exists($ie6css)) { $styledata = JFile::read($ie6css); $newtext = preg_replace("/src=( )*'( )*([^' ]+)'/i", "src='" . JURI::root(true) . "\\3" . "'", $styledata); $newtext = preg_replace("/url\\(( )*'( )*([^' ]+)'/i", "url('" . JURI::root(true) . "\\3" . "'", $newtext); $newtext = preg_replace("/\\." . $faqclassarray[$i] . "/", "#" . $faqid . "." . $faqclassarray[$i], $newtext); $document->addStyleDeclaration($newtext); } } } else { if ($warnings == 'tru') { $warntext = "WARNING: CSS file for faqclass " . $faqclassarray[$i] . " does not exist (" . $faqfile . ")."; $html .= $this->_formattedError($warntext, $faqline); } } } else { if ($warnings == 'tru') { if (!$this->_editFaqClass($faqclassarray[$i], $warntext)) { $html .= $this->_formattedError($warntext, $faqline); } } } } $includejquery = $params->get('includejquery', 1); if ($includejquery != 0) { $jquerynoconflict = $params->get('jquerynoconflict', 1); if ($jquerynoconflict == 1) { JHTML::_('jquery.framework'); } else { JHTML::_('jquery.framework', false); } } JHTML::_('script', 'plugins/content/accordionfaq/js/preparefaq.js'); if ($openmultiple == 'tru' && $animation !== 'false') { $duration = 300; $easing = 'swing'; if ($animation == "'slide'") { $duration = 300; $easing = 'swing'; } else { if ($animation == "'easeslide'") { $duration = 700; $easing = 'easeinout'; } else { if ($animation == "'bounceslide'") { $duration = 1000; $easing = 'bounceout'; } } } } $script = "// <!--\n"; $script .= "preparefaq.onFunctionAvailable( 'jQuery', 300, function() {\n"; $script .= "\tpreparefaq.setjQuery();\n"; if ($printfaq === 'false' && $openmultiple == 'fals') { $script .= "\tpreparefaq.loadScript( '" . JURI::root(true) . "/plugins/content/accordionfaq/js/jquery.accordionfaq.js' );\n"; } if ($animation !== "false") { $script .= "\tpreparefaq.loadScript( '" . JURI::root(true) . "/plugins/content/accordionfaq/js/jquery.easing.js' );\n"; } $script .= "/***********************************************\n"; $script .= "* Scrolling HTML bookmarks- © Dynamic Drive DHTML code library (www.dynamicdrive.com)\n"; $script .= "* This notice MUST stay intact for legal use\n"; $script .= "* Visit Project Page at http://www.dynamicdrive.com for full source code\n"; $script .= "***********************************************/\n"; $script .= "\tpreparefaq.loadScript( '" . JURI::root(true) . "/plugins/content/accordionfaq/js/bookmarkscroll.js' );\n"; $script .= "\tpreparefaq.getjQuery()(document).ready(function(){ \n"; $script .= "\t\tpreparefaq.exec( { \n"; $script .= "\t\t id: '" . $faqid . "'\n"; $script .= "\t\t , header: '" . $header . "'\n"; $script .= "\t\t , alwaysopen: " . $alwaysopen . "e\n"; $script .= "\t\t , autonumber: " . $autonumber . "e\n"; $script .= "\t\t , keyaccess: " . $keyaccess . "e\n"; $script .= "\t\t , print: " . $printfaq . "\n"; $script .= "\t\t , scrolltime: " . $scrolltime . "\n"; $script .= "\t\t , scrolloffset: " . $scrolloffset . "\n"; if ($faqlinks != "") { $script .= "\t\t , faqlinks: '" . $faqlinks . "'\n"; } $script .= "\t\t , scrollonopen: " . $scrollonopen . "e\n"; if ($openmultiple == 'tru') { $script .= "\t\t , event: '" . $event . "'\n"; $script .= "\t\t , onevent: function() { \n"; if ($animation === 'false') { $script .= "\t\t\t\tpreparefaq.getjQuery()(this).toggleClass('selected').next().toggle( 1, preparefaq.accordionChange );\n"; } else { $script .= "\t\t\t\tpreparefaq.getjQuery()(this).toggleClass('selected').next().slideToggle( " . $duration . ", '" . $easing . "', preparefaq.accordionChange );\n"; } $script .= "\t\t\t\treturn false;\n"; $script .= "\t\t\t}\n"; } $script .= "\t\t} );\n"; $script .= "\t\tpreparefaq.onFunctionAvailable( 'bookmarkscroll.init', 300, function() {\n"; $script .= "\t\t\t\tbookmarkscroll.init();\n"; $script .= "\t\t});\n"; if ($openmultiple == 'tru') { $script .= "\t\tpreparefaq.getjQuery()('#" . $faqid . "').addClass('selected');\n"; if ($activearr[0] !== 'false' && $printfaq === 'false') { if (count($activearr) == 1 && $activearr[0] == "'#*'") { $script .= "\t\tpreparefaq.getjQuery()('" . $header . ".accordionfaqheader." . $faqid . "').toggleClass('selected').next().toggle();\n"; } else { $script .= "\t\tvar target;\n"; for ($i = 0; $i < count($activearr); $i++) { if (is_numeric($activearr[$i])) { $script .= "\t\ttarget = preparefaq.getjQuery()('#" . $faqid . $activearr[$i] . "');\n"; } else { $activeval = str_replace("'", '', $activearr[$i]); $script .= "\t\ttarget = preparefaq.getjQuery()('" . $activeval . "');\n"; } $script .= "\t\tif (typeof(target) !== 'undefined') {\n"; $script .= "\t\t\ttarget.toggleClass('selected').next().toggle();\n"; $script .= "\t\t};\n"; } } } } else { $script .= "\t\tpreparefaq.onFunctionAvailable( 'preparefaq.getjQuery().fn.accordionfaq', 300, function() {\n"; $script .= "\t\t\tpreparefaq.getjQuery()('#" . $faqid . "').accordionfaq( { \n"; $script .= "\t\t\t\t header: '" . $header . ".accordionfaqheader." . $faqid . "'\n"; $script .= "\t\t\t\t, autoheight: " . $autoheight . "e\n"; $script .= "\t\t\t\t, alwaysOpen: " . $alwaysopen . "e\n"; $script .= "\t\t\t\t, active: " . $activearr[0] . "\n"; $script .= "\t\t\t \t, animated: " . $animation . "\n"; $script .= "\t\t\t \t, event: '" . $event . "'\n"; $script .= "\t\t\t});\n"; $script .= "\t\t\tpreparefaq.getjQuery()('#" . $faqid . "').bind( 'change.faq-accordion', preparefaq.accordionChangeUI );\n"; $script .= "\t\t});\n"; } if (isset($jumpto)) { $script .= "\t\tpreparefaq.onIdAvailable( '" . $jumpto . "', 300, function() {\n"; $script .= "\t\t\tpreparefaq.onFunctionAvailable( 'bookmarkscroll.scrollTo', 300, function() {\n"; $script .= "\t\t\t\tpreparefaq.jumpToFaqItem( '" . $jumpto . "' );\n"; $script .= "\t\t\t});\n"; $script .= "\t\t});\n"; } $script .= "\t});\n"; $script .= "});\n"; $script .= "// -->\n"; $document->addScriptDeclaration($script); $html .= "<div id=\"" . $faqid . "\" class=\"accordionfaq " . $faqclass . "\">"; $html .= "<p></p>"; $html .= "</div>"; return $html; }
/** * Formats the message * * @since 1.0 * @access public * @param string * @return */ public function formatMessage($params) { $withData = $params->get('with_data'); if ($withData) { // dump( $withData ); } $storyTags = $params->get('story_tags'); $message = $params->get('content'); if ($storyTags) { foreach ($storyTags as $tag) { $message = JString::substr_replace($message, '<a href="' . $tag->link . '">' . $tag->name . '</a>', $tag->offset, $tag->length); } } return $message; }
$fullimg = JString::substr($item->fulltext, $pos, $fin - $pos); $fin = JString::strpos($item->fulltext, '>', $fin); } $intronoimage = $item->introtext; while (($ini = JString::strpos($intronoimage, '<img')) !== false) { if (($fin = JString::strpos($intronoimage, '>', $ini)) === false) { break; } $intronoimage = JString::substr_replace($intronoimage, '', $ini, $fin - $ini + 1); } $fullnoimage = $item->fulltext; while (($ini = JString::strpos($fullnoimage, '<img')) !== false) { if (($fin = JString::strpos($fullnoimage, '>', $ini)) === false) { break; } $fullnoimage = JString::substr_replace($fullnoimage, '', $ini, $fin - $ini + 1); } $title = $rowmaxtitle ? JString::substr(strip_tags($item->title), 0, $rowmaxtitle) . $rowmaxtitlesuf : strip_tags($item->title); $intro = $rowmaxintro ? JString::substr(strip_tags($item->introtext), 0, $rowmaxintro) . $rowmaxintrosuf : strip_tags($item->introtext); $rawfulltext = $item->fulltext; $fulltext = strip_tags($item->fulltext); if (!empty($rowtextbrk)) { $pos = JString::strpos($rawfulltext, $rowtextbrk); if ($pos !== false) { $rawfulltext = substr($rawfulltext, 0, $pos + strlen($rowtextbrk)); } $pos = JString::strpos($fulltext, $rowtextbrk); if ($pos !== false) { $fulltext = JString::substr($fulltext, 0, $pos + strlen($rowtextbrk)); } $pos = JString::strpos($intronoimage, $rowtextbrk);