/** * Overloaded check function * * @return boolean True on success * * @see JTable::check * @since 11.1 */ public function check() { // If the alias field is empty, set it to the title. $this->alias = trim($this->alias); if (empty($this->alias) && ($this->type != 'alias' && $this->type != 'url')) { $this->alias = $this->title; } // Make the alias URL safe. $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); } // Cast the home property to an int for checking. $this->home = (int) $this->home; // Verify that a first level menu item alias is not 'component'. if ($this->parent_id == 1 && $this->alias == 'component') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT')); return false; } // Verify that a first level menu item alias is not the name of a folder. jimport('joomla.filesystem.folder'); if ($this->parent_id == 1 && in_array($this->alias, JFolder::folders(JPATH_ROOT))) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias)); return false; } // Verify that the home item a component. if ($this->home && $this->type != 'component') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT')); return false; } return true; }
protected function prepareTable($table) { jimport('joomla.filter.output'); $date = JFactory::getDate(); $user = JFactory::getUser(); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->alias = JApplication::stringURLSafe($table->alias); if (empty($table->alias)) { $table->alias = JApplication::stringURLSafe($table->title); } // Set the publish date to now if ($table->published == 1 && intval($table->publish_up) == 0) { $table->publish_up = $date->toSql(); } /* if (empty($table->id)) { // Set ordering to the last item if not set if (empty($table->ordering)) { $table->ordering = 0; $db = JFactory::getDbo(); $query = 'SELECT MAX(ordering) FROM #__djmt_items'; if($table->catid) $query.= ' WHERE catid='. (int) $table->catid; $db->setQuery($query); $max = $db->loadResult(); $table->ordering = $max+1; } }*/ }
/** * Overloaded check function * * @return boolean * @see JTable::check * @since 1.5 */ function check() { // Require helper require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'je_content.php'; jimport('joomla.filter.output'); // Set title $this->title = htmlspecialchars_decode($this->title, ENT_QUOTES); // Set alias $this->alias = JE_ContentHelper::convertAlias($this->title); $this->alias = JApplication::stringURLSafe($this->alias); // Check the publish down date is not earlier than publish up. if (intval($this->publish_down) > 0 && $this->publish_down < $this->publish_up) { // Swap the dates. $temp = $this->publish_up; $this->publish_up = $this->publish_down; $this->publish_down = $temp; } // Set ordering if ($this->state < 0) { // Set ordering to 0 if state is archived or trashed $this->ordering = 0; } else { if (empty($this->ordering)) { // Set ordering to last if ordering was 0 $this->ordering = self::getNextOrder('`catid`=' . $this->_db->Quote($this->catid) . ' AND state>=0'); } } return true; }
protected function prepareTable($table) { jimport('joomla.filter.output'); $date = JFactory::getDate(); $user = JFactory::getUser(); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->alias = JApplication::stringURLSafe($table->alias); if (empty($table->alias)) { $table->alias = JApplication::stringURLSafe($table->title); } if (intval($table->date) == 0) { $table->date = JFactory::getDate()->toSql(); } if (empty($table->id)) { // Set the values //$table->created = $date->toSql(); // Set ordering to the last item if not set if (empty($table->ordering)) { $db = JFactory::getDbo(); $db->setQuery('SELECT MAX(ordering) FROM #__phocagallery_comments WHERE catid = ' . (int) $table->catid); $max = $db->loadResult(); $table->ordering = $max + 1; } } else { // Set the values //$table->modified = $date->toSql(); //$table->modified_by = $user->get('id'); } }
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); }
function check() { jimport('joomla.filter.output'); $this->name = htmlspecialchars_decode($this->name, ENT_QUOTES); if (empty($this->ordering)) { $this->ordering = self::getNextOrder(); } if (empty($this->alias)) { $this->alias = $this->name; } $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('1', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); } $this->alias = str_replace("-", "_", $this->alias); if ($this->type == '0') { return false; } if (is_array($_REQUEST['jform']['type_' . $this->type])) { $_REQUEST['jform']['type_' . $this->type]['value'] = $this->remove_array_empty_values($_REQUEST['jform']['type_' . $this->type]['value']); $_REQUEST['jform']['type_' . $this->type] = serialize($_REQUEST['jform']['type_' . $this->type]); } if ($this->type != 'image') { $this->default_values = $_REQUEST['jform']['type_' . $this->type]; } return true; }
/** * Check */ public function check() { // check title if (trim($this->title) == '') { $this->setError(JText::_('COM_JKIT_TAG_ERROR_TITLE')); return false; } // / create alias from title, and make safe $this->alias = JApplication::stringURLSafe($this->title); if (trim(str_replace('-', '', $this->alias)) == '') { $this->setError(JText::_('COM_JKIT_TAG_ERROR_ALIAS')); return false; } // verify unique alias $table = JTable::getInstance('Tag', 'JKitTable', array('dbo' => $this->getDbo())); if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) { $this->setError(JText::_('COM_JKIT_TAG_ERROR_ALIAS')); return false; } // check translations titles and alias if ($this->language != '*') { $db = JFactory::getDbo(); $langs = JKitHelperLangs::getLangs(); foreach ($langs as $lang) { if ($this->language != $lang->lang_code) { // check translation title $t_title = trim(JRequest::getString('translation_title_' . $lang->lang_code)); if ($t_title == '') { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_TITLE', $lang->title)); return false; } // check translation alias $t_alias = JApplication::stringURLSafe($t_title); if (trim(str_replace('-', '', $t_alias)) == '') { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title)); return false; } // check translation repeated alias $q_l = $db->quote($lang->lang_code); $q_a = $db->quote($t_alias); $ref_id = $this->id ? " AND `ref_id` != {$this->id}" : ''; $q1 = "SELECT `ref_id` FROM `#__jkit_translations` WHERE `ref_table` = 'tags' AND `alias` = {$q_a} AND `lang` = {$q_l} {$ref_id}"; $t_ids1 = $db->setQuery($q1)->loadColumn(); if ($t_ids1) { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title)); return false; } // check duplicated tags in different languages $tid = $this->id ? " AND id != {$this->id}" : ''; $q2 = "SELECT `id` FROM `#__jkit_tags` WHERE `alias` = {$q_a} AND `language` = {$q_l} {$tid}"; $t_ids2 = $db->setQuery($q2)->loadColumn(); if ($t_ids2) { $this->setError(JText::sprintf('COM_JKIT_TAG_ERROR_TRANSLATION_ALIAS', $lang->title)); return false; } } } } return true; }
public function store($updateNulls = false) { $isNew = false; if (!$this->id) { // New document $this->downloaded = 0; $isNew = true; } if (isset($this->alias) && isset($this->name) && $this->alias == "") { $this->alias = preg_replace("/ /", "-", strtolower($this->name)); } if (version_compare(JVERSION, '3.0', '>=')) { $this->alias = JApplicationHelper::stringURLSafe($this->alias); } else { $this->alias = JApplication::stringURLSafe($this->alias); } // Trigger events to osdownloads plugins $dispatcher = $this->getDispatcher(); $pluginResults = $dispatcher->trigger('onOSDownloadsBeforeSaveFile', array(&$this, $isNew)); $result = false; if ($pluginResults !== false) { $result = parent::store($updateNulls); $dispatcher->trigger('onOSDownloadsAfterSaveFile', array($result, &$this)); } return $result; }
/** * Overloaded check function * * @return boolean True on success, false on failure */ public function check() { if (trim($this->title) == '') { $this->setError(JText::_('COM_PROJECTFORK_WARNING_PROVIDE_VALID_TITLE')); return false; } if (trim($this->alias) == '') { $this->alias = $this->title; } $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JApplication::stringURLSafe(JFactory::getDate()->format('Y-m-d-H-i-s')); } // Check attribs $registry = new JRegistry(); $registry->loadString($this->attribs); $this->attribs = (string) $registry; // Check if a project is selected if ((int) $this->project_id <= 0) { $this->setError(JText::_('COM_PROJECTFORK_WARNING_SELECT_PROJECT')); return false; } // Check for selected access level if ($this->access <= 0) { $this->access = $this->_getParentAccess(); } return true; }
/** * Check if a category exists * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return * @since 4.3 */ public function check() { $db = JFactory::getDbo(); $query = $db->getQuery(true); // Check if the category exists $query->select('id'); $query->from('#__ezrealty_catg'); $query->where($db->qn('name') . ' = ' . $db->quote($this->name)); $db->setQuery($query); $catid = $db->loadResult(); if ($catid > 0) { $this->id = $catid; } else { // Check the alias if (empty($this->alias)) { $this->alias = JApplication::stringURLSafe($this->name); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); } } // Check the access if (empty($this->access)) { $this->access = 1; } } }
/** * Overloaded check function * * @return boolean * @see JTable::check * @since 1.5 */ function check() { if (empty($this->name)) { $this->name = "form_" . self::getNextOrder(); } // Remove accented UTF-8 charachters in field name $this->name = JApplication::stringURLSafe($this->name, ENT_QUOTES); // Set label if (empty($this->title)) { $this->title = $this->name; } // Check upload directory JLoader::import('joomla.filesystem.folder'); //convert backslashes to slashes $uploadpath = preg_replace('#\\\\#', '/', $this->uploadpath); $this->uploadpath = $uploadpath; //remove slashes at the beginning and the end of string $this->uploadpath = rtrim($this->uploadpath, '/'); $this->uploadpath = ltrim($this->uploadpath, '/'); $check = trim($this->uploadpath); if (!empty($check)) { $check = JPath::clean($check); if (!JFolder::exists($this->uploadpath)) { $directory = JPATH_SITE . '/' . $this->uploadpath; if (!JFolder::exists($directory)) { $this->setError(JText::_('COM_VISFORMS_DIRECTORY_DOESNT_EXISTS')); return false; } } } else { $this->setError(JText::_('COM_VISFORMS_DIRECTORY_EMPTY')); return false; } return true; }
/** * Overloaded check function * * @return boolean * @see JTable::check * @since 1.5 */ function check() { // Set name $this->name = htmlspecialchars_decode($this->name, ENT_QUOTES); // Set alias $this->alias = JApplication::stringURLSafe($this->alias); if (empty($this->alias)) { $this->alias = JApplication::stringURLSafe($this->name); } // Check the publish down date is not earlier than publish up. if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) { // Swap the dates. $temp = $this->publish_up; $this->publish_up = $this->publish_down; $this->publish_down = $temp; } // Set ordering if ($this->state < 0) { // Set ordering to 0 if state is archived or trashed $this->ordering = 0; } elseif (empty($this->ordering)) { // Set ordering to last if ordering was 0 $this->ordering = self::getNextOrder($this->_db->quoteName('catid') . '=' . $this->_db->Quote($this->catid) . ' AND state>=0'); } return true; }
/** * Overloaded check function * * @return boolean True on success, false on failure * * @see JTable::check * @since 11.1 */ public function check() { $this->menutype = JApplication::stringURLSafe($this->menutype); if (empty($this->menutype)) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENUTYPE_EMPTY')); return false; } // Sanitise data. if (trim($this->title) == '') { $this->title = $this->menutype; } // Check for unique menutype. $query = $this->_db->getQuery(true); $query->select('COUNT(id)'); $query->from($this->_db->quoteName('#__menu_types')); $query->where($this->_db->quoteName('menutype') . ' = ' . $this->_db->quote($this->menutype)); $query->where($this->_db->quoteName('id') . ' <> ' . (int) $this->id); $this->_db->setQuery($query); if ($this->_db->loadResult()) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENUTYPE_EXISTS', $this->menutype)); return false; } return true; }
/** * Overloaded check function * * @return boolean * @see JTable::check * @since 1.5 */ function check() { if (empty($this->name)) { $this->name = "field-" . self::getNextOrder($this->_db->quoteName('fid') . '=' . $this->_db->Quote($this->fid)); } //When we submit a form fields are added to the $Request with the field name as request parameter name. //If a field name matches a default request parameter (like id) this will be overridden with the user input for the form field. //This can cause strange errors $forbiddenFieldNames = array('id', 'fid', 'view', 'task', 'option', 'lang', 'language', 'itemid', 'restrictions'); foreach ($forbiddenFieldNames as $fvalue) { if ($this->name == $fvalue) { $this->name = "field-" . self::getNextOrder($this->_db->quoteName('fid') . '=' . $this->_db->Quote($this->fid)); JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_VISFORMS_INVALID_FIELD_NAME_REPLACED', $fvalue, $this->name), 'warning'); } } // Remove accented UTF-8 charachters in field name $this->name = JApplication::stringURLSafe($this->name, ENT_QUOTES); // Set label if (empty($this->label)) { $this->label = $this->name; } // Set ordering if (empty($this->ordering)) { // Set ordering to last if ordering was 0 $this->ordering = self::getNextOrder($this->_db->quoteName('fid') . '=' . $this->_db->Quote($this->fid)); } return true; }
/** * Overloaded check function * * @return boolean True on success, false on failure * * @see JTable::check * @since 11.1 */ function check() { $this->menutype = JApplication::stringURLSafe($this->menutype); if (empty($this->menutype)) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENUTYPE_EMPTY')); return false; } // Sanitise data. if (trim($this->title) == '') { $this->title = $this->menutype; } $db = $this->getDbo(); // Check for unique menutype. $db->setQuery( 'SELECT COUNT(id)' . ' FROM #__menu_types' . ' WHERE menutype = '.$db->quote($this->menutype). ' AND id <> '.(int) $this->id ); if ($db->loadResult()) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENUTYPE_EXISTS', $this->menutype)); return false; } return true; }
public function check() { // Check for valid name if (trim($this->title) == '') { $this->setError(JText::_('COM_FIELDS_LOCATION_ERR_TABLES_TITLE')); return false; } if (empty($this->alias)) { $this->alias = $this->title; } $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JString::increment($alias, 'dash'); } $this->alias = str_replace(',', '-', $this->alias); if (empty($this->type)) { $this->type = 'text'; } // Check the publish down date is not earlier than publish up. if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) { $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH')); return false; } if (is_array($this->catid)) { $this->catid = implode(',', $this->catid); } return true; }
/** * Overloaded check function * * @return boolean * @see JTable::check * @since 1.5 */ function check() { jimport('joomla.filter.output'); // Set name $this->name = htmlspecialchars_decode($this->name, ENT_QUOTES); // Set alias $this->alias = JApplication::stringURLSafe($this->alias); if (empty($this->alias)) { $this->alias = JApplication::stringURLSafe($this->name); } // Check the publish down date is not earlier than publish up. if (intval($this->publish_down) > 0 && $this->publish_down < $this->publish_up) { // Swap the dates. $temp = $this->publish_up; $this->publish_up = $this->publish_down; $this->publish_down = $temp; } // Set ordering if ($this->state < 0) { // Set ordering to 0 if state is archived or trashed $this->ordering = 0; } else { if (empty($this->ordering)) { // Set ordering to last if ordering was 0 $this->ordering = self::getNextOrder('`catid`=' . $this->_db->Quote($this->catid) . ' AND state>=0'); } } return true; }
/** * Overloaded check function * * @return boolean * */ public function check() { // Set name $this->name = htmlspecialchars_decode($this->name, ENT_QUOTES); // Set alias $this->alias = JApplication::stringURLSafe($this->alias); if (empty($this->alias)) { $this->alias = JApplication::stringURLSafe($this->name); } // Verify that the alias is unique - by this stage it should always be but this is a final check $table = JTable::getInstance('Selecties', 'Knvbapi2Table'); if ($table->load(array('alias' => $this->alias)) and ($table->id != $this->id or $this->id == 0)) { $this->setError(JText::_('COM_KNVBAPI2_FIELD_ALIAS_DUPLICATED')); return false; } // Set ordering if ($this->state < 0) { // Set ordering to 0 if state is trashed $this->ordering = 0; } else { if (empty($this->ordering)) { // Set ordering to last if ordering was 0 $additional_order = ''; $this->ordering = self::getNextOrder($additional_order . ' state>=0'); } } // Check the publish down date is not earlier than publish up. if (intval($this->publish_down) > 0 and $this->publish_down < $this->publish_up) { $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH')); return false; } // clean up keywords -- eliminate extra spaces between phrases // and cr (\r) and lf (\n) characters from string if (!empty($this->metakey)) { // only process if not empty $bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove $after_clean = str_replace($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 (JString::trim($key)) { // ignore blank keywords $clean_keys[] = JString::trim($key); } } $this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", " } // clean up description -- eliminate quotes and <> brackets if (!empty($this->metadesc)) { // only process if not empty $bad_characters = array("\"", "<", ">"); $this->metadesc = str_replace($bad_characters, "", $this->metadesc); } return true; }
function check() { jimport('joomla.filter.output'); $this->title = JString::trim($this->title); if ($this->title == '') { $this->setError(JText::_('K2_ITEM_MUST_HAVE_A_TITLE')); return false; } if (!$this->catid) { $this->setError(JText::_('K2_ITEM_MUST_HAVE_A_CATEGORY')); return false; } if (empty($this->alias)) { $this->alias = $this->title; } if (K2_JVERSION != '15' && JFactory::getConfig()->get('unicodeslugs') == 1) { $this->alias = JApplication::stringURLSafe($this->alias); } else { if (JPluginHelper::isEnabled('system', 'unicodeslug') || JPluginHelper::isEnabled('system', 'jw_unicodeSlugsExtended')) { $this->alias = JFilterOutput::stringURLSafe($this->alias); } else { mb_internal_encoding("UTF-8"); mb_regex_encoding("UTF-8"); $this->alias = trim(mb_strtolower($this->alias)); $this->alias = str_replace('-', ' ', $this->alias); $this->alias = str_replace('/', '-', $this->alias); $this->alias = mb_ereg_replace('[[:space:]]+', ' ', $this->alias); $this->alias = trim(str_replace(' ', '-', $this->alias)); $this->alias = str_replace('.', '', $this->alias); $this->alias = str_replace('"', '', $this->alias); $this->alias = str_replace("'", '', $this->alias); $stripthese = ',|~|!|@|%|^|(|)|<|>|:|;|{|}|[|]|&|`|„|‹|’|‘|“|â€�|•|›|«|´|»|°|«|»|…'; $strips = explode('|', $stripthese); foreach ($strips as $strip) { $this->alias = str_replace($strip, '', $this->alias); } $params = JComponentHelper::getParams('com_k2'); $SEFReplacements = array(); $items = explode(',', $params->get('SEFReplacements')); foreach ($items as $item) { if (!empty($item)) { @(list($src, $dst) = explode('|', trim($item))); $SEFReplacements[trim($src)] = trim($dst); } } foreach ($SEFReplacements as $key => $value) { $this->alias = str_replace($key, $value, $this->alias); } $this->alias = trim($this->alias, '-.'); if (trim(str_replace('-', '', $this->alias)) == '') { $datenow = JFactory::getDate(); $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); } } } return true; }
function display($tpl = null) { $dispatcher = JDispatcher::getInstance(); // Get data from the model $items = $this->get('Items'); // Check for errors. if (count($errors = $this->get('Errors'))) { $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Problem with datadase request: ' . implode("\r\n", $errors), 'priority' => JLog::ERROR, 'section' => 'site'))); return false; } //Load helper files JLoader::import('helpers.download', JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_playjoom'); JLoader::import('helpers.playlist', JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_playjoom'); // Create folder name if (JRequest::getVar('source') == 'album') { $foldername = JApplication::stringURLSafe(base64_decode(JRequest::getVar('artist'))) . ' - ' . JApplication::stringURLSafe(base64_decode(JRequest::getVar('name'))); } else { $foldername = JApplication::stringURLSafe(base64_decode(JRequest::getVar('name'))); } $CreateArchivFile = new PlayJoomHelperDownload(); // Add the info file into the archive $CreateInfoFile = new PlayJoomHelperPlaylist(); $CreateInfoFile->createInfoFile($items); $CreateArchivFile->addFile($CreateInfoFile->file(), $foldername . DIRECTORY_SEPARATOR . 'readme.txt'); // Add the playlist files into the archive $CreateM3UPlaylistFile = new PlayJoomHelperPlaylist(); $CreateM3UPlaylistFile->CreateM3UList($items, true); $CreateArchivFile->addFile($CreateM3UPlaylistFile->file(), $foldername . DIRECTORY_SEPARATOR . 'playlist.m3u'); $CreatePLSPlaylistFile = new PlayJoomHelperPlaylist(); $CreatePLSPlaylistFile->CreatePLSList($items, true); $CreateArchivFile->addFile($CreatePLSPlaylistFile->file(), $foldername . DIRECTORY_SEPARATOR . 'playlist.pls'); $CreateXSPFPlaylistFile = new PlayJoomHelperPlaylist(); $CreateXSPFPlaylistFile->CreateXSPFList($items, true); $CreateArchivFile->addFile($CreateXSPFPlaylistFile->file(), $foldername . DIRECTORY_SEPARATOR . 'playlist.xspf'); $CreateWPLPlaylistFile = new PlayJoomHelperPlaylist(); $CreateWPLPlaylistFile->CreateWPLList($items, true); $CreateArchivFile->addFile($CreateWPLPlaylistFile->file(), $foldername . DIRECTORY_SEPARATOR . 'playlist.wpl'); $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Ready for to create a download archiv file: ' . JApplication::stringURLSafe(JRequest::getVar('name')) . '.zip', 'priority' => JLog::INFO, 'section' => 'site'))); // Add the audio files into the archive foreach ($items as $i => $item) { if (JRequest::getVar('source') == 'album') { $filename = $item->tracknumber . ' - ' . JApplication::stringURLSafe($item->title) . '.' . PlayJoomHelper::getFileExtension($item->mediatype); } else { $filename = $i + 1 . ' - ' . JApplication::stringURLSafe($item->artist) . ' - ' . JApplication::stringURLSafe($item->title) . '.' . PlayJoomHelper::getFileExtension($item->mediatype); } $CreateArchivFile->addFile(file_get_contents($item->pathatlocal . DIRECTORY_SEPARATOR . $item->file), $foldername . DIRECTORY_SEPARATOR . $filename); } // Add cover file into archive, if once existing. $covercontent = PlayJoomHelper::getAlbumCover(base64_decode(JRequest::getVar('name')), base64_decode(JRequest::getVar('artist'))); if ($covercontent) { $CreateArchivFile->addFile($covercontent->data, $foldername . DIRECTORY_SEPARATOR . 'cover.' . PlayJoomHelper::getFileExtension($covercontent->mime)); } $CreateArchivFile->setHeader(JApplication::stringURLSafe($foldername) . '.zip', 'application/zip', mb_strlen($CreateArchivFile->file(), '8bit')); // Send the archiv $CreateArchivFile->send($CreateArchivFile->file()); }
public static function getUserRoute($userID) { if (K2_CB) { global $_CB_framework; return $_CB_framework->userProfileUrl((int) $userID); } $key = (int) $userID; if (isset(self::$cache['user'][$key])) { return self::$cache['user'][$key]; } $needles = array('user' => (int) $userID); $user = JFactory::getUser($userID); if (K2_JVERSION != '15' && JFactory::getConfig()->get('unicodeslugs') == 1) { $alias = JApplication::stringURLSafe($user->name); } else { if (JPluginHelper::isEnabled('system', 'unicodeslug') || JPluginHelper::isEnabled('system', 'jw_unicodeSlugsExtended')) { $alias = JFilterOutput::stringURLSafe($user->name); } else { mb_internal_encoding("UTF-8"); mb_regex_encoding("UTF-8"); $alias = trim(mb_strtolower($user->name)); $alias = str_replace('-', ' ', $alias); $alias = mb_ereg_replace('[[:space:]]+', ' ', $alias); $alias = trim(str_replace(' ', '', $alias)); $alias = str_replace('.', '', $alias); $stripthese = ',|~|!|@|%|^|(|)|<|>|:|;|{|}|[|]|&|`|„|‹|’|‘|“|â€�|•|›|«|´|»|°|«|»|…'; $strips = explode('|', $stripthese); foreach ($strips as $strip) { $alias = str_replace($strip, '', $alias); } $params = K2HelperUtilities::getParams('com_k2'); $SEFReplacements = array(); $items = explode(',', $params->get('SEFReplacements', NULL)); foreach ($items as $item) { if (!empty($item)) { @(list($src, $dst) = explode('|', trim($item))); $SEFReplacements[trim($src)] = trim($dst); } } foreach ($SEFReplacements as $key => $value) { $alias = str_replace($key, $value, $alias); } $alias = trim($alias, '-.'); if (trim(str_replace('-', '', $alias)) == '') { $datenow = JFactory::getDate(); $alias = K2_JVERSION == '15' ? $datenow->toFormat("%Y-%m-%d-%H-%M-%S") : $datenow->format("Y-m-d-H-i-s"); } } } $link = 'index.php?option=com_k2&view=itemlist&task=user&id=' . $userID . ':' . $alias; if ($item = K2HelperRoute::_findItem($needles)) { $link .= '&Itemid=' . $item->id; } self::$cache['user'][$key] = $link; return $link; }
protected function prepareTable($table) { $date = JFactory::getDate(); $user = JFactory::getUser(); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->alias = JApplication::stringURLSafe($table->alias); if (empty($table->alias)) { $table->alias = JApplication::stringURLSafe($table->title); } }
/** * Function to export donor list to CSV. * * @return void * * @since 1.0.0 */ public function export_donors() { $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_cmdonation'); $campaignId = $app->input->get('campaign', 0, 'integer'); // Make sure campaign exists. $campaign = JModelAdmin::getInstance('Campaign', 'CMDonationModel')->getItem($campaignId); if (empty($campaign)) { $app->enqueueMessage(JText::_('COM_CMDONATION_CAMPAIGN_NOT_FOUND'), 'error'); $app->redirect(JRoute::_('index.php?option=com_cmdonation')); } // Get campaign's donations. $donations = JModelAdmin::getInstance('Donations', 'CMDonationModel')->getDonationsForCSV($campaignId); $data = array(array(JText::_('COM_CMDONATION_DONATION_FIRST_NAME_LABEL'), JText::_('COM_CMDONATION_DONATION_LAST_NAME_LABEL'), JText::_('COM_CMDONATION_DONATION_EMAIL_LABEL'), JText::_('COM_CMDONATION_DONATION_COUNTRY_LABEL'), JText::_('COM_CMDONATION_DONATION_AMOUNT_LABEL'), JText::_('COM_CMDONATION_DONATION_COMPLETED_LABEL'), JText::_('COM_CMDONATION_DONATION_PAYMENT_METHOD_LABEL'))); if (!empty($donations)) { include JPATH_ROOT . '/administrator/components/com_cmdonation/helpers/countries.php'; $currencySign = $params->get('currency_sign'); $currencySignPosition = $params->get('currency_sign_position'); $decimals = $params->get('decimals'); $decimalPoint = $params->get('decimal_point'); $thousandSeparator = $params->get('thousand_separator'); foreach ($donations as $donation) { if (array_key_exists($donation->country_code, $countryList)) { $countryName = JText::_($countryList[$donation->country_code]); } else { $countryName = ''; } $amount = CMDonationHelper::showDonationAmount($donation->amount, $currencySign, $currencySignPosition, $decimals, $decimalPoint, $thousandSeparator, false); $paymentMethod = CMDonationHelper::displayPaymentMethodName($donation->payment_method_id); $data[] = array($donation->first_name, $donation->last_name, $donation->email, $countryName, $amount, $donation->completed, $paymentMethod); } } $delimiter = $params->get('csv_delimiter_character', ','); $enclosure = $params->get('csv_enclosure_character', 'double'); if ($enclosure == 'double') { $enclosure = '"'; } else { $enclosure = "'"; } $filename = JApplication::stringURLSafe($campaign->name); if ($filename == '') { $filename = JFactory::getDate()->format("Y-m-d-H-i-s"); } $filename .= '.csv'; header("Content-type: text/csv"); header("Content-Disposition: attachment; filename={$filename}"); header("Pragma: no-cache"); header("Expires: 0"); $output = fopen("php://output", "w"); foreach ($data as $row) { fputcsv($output, $row, $delimiter, $enclosure); } fclose($output); JFactory::getApplication()->close(); }
function check() { if (empty($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"); } return true; }
/** * Sluggifies the input string. * * @param string $string input string * @param bool $force_safe Do we have to enforce ASCII instead of UTF8 (default: false) * * @return string sluggified string * @since 2.0 */ public function sluggify($string, $force_safe = false) { $string = $this->strtolower((string) $string); $string = $this->str_ireplace(array('$', ','), '', $string); if ($force_safe) { $string = JFilterOutput::stringURLSafe($string); } else { $string = JApplication::stringURLSafe($string); } return trim($string); }
function bind($array, $ignore = '') { if (empty($array['alias'])) { $array['alias'] = $array['name']; } $array['alias'] = JApplication::stringURLSafe($array['alias']); if (trim(str_replace('-', '', $array['alias'])) == '') { $array['alias'] = JFactory::getDate()->format('Y-m-d-H-i-s'); } return parent::bind($array, $ignore); }
function display($tpl = null) { $dispatcher = JDispatcher::getInstance(); // Get data from the model $items = $this->get('Items'); //Get setting values from xml file $app = JFactory::getApplication(); $params = $app->getParams(); // Check for errors. if (count($errors = $this->get('Errors'))) { $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Problem with datadase request: ' . implode("\r\n", $errors), 'priority' => JLog::ERROR, 'section' => 'site'))); return false; } //Load playlist helper JLoader::import('helpers.playlist', JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_playjoom'); $PlaylistFile = new PlayJoomHelperPlaylist(); if (JRequest::getVar('attachment_playlist') != '') { $listtype = JRequest::getVar('attachment_playlist'); } else { $listtype = $params->get('playlist_type', 'm3u'); } $filename = base64_decode(JRequest::getVar('name')); if ($filename != '' && JRequest::getVar('disposition') == 'attachment') { $playlistFileName = JApplication::stringURLSafe($filename) . '.' . $listtype; } else { $playlistFileName = 'playlist.' . $listtype; } switch ($listtype) { case 'pls': $PlaylistFile->CreatePLSList($items, false); $PlaylistFile->setHeader($playlistFileName, 'application/pls+xml', mb_strlen($PlaylistFile->file(), '8bit')); break; case 'm3u': $PlaylistFile->CreateM3UList($items, false); $PlaylistFile->setHeader($playlistFileName, 'audio/x-mpegurl', mb_strlen($PlaylistFile->file(), '8bit')); break; case 'xspf': $PlaylistFile->CreateXSPFList($items, false); $PlaylistFile->setHeader($playlistFileName, 'application/xspf+xml', mb_strlen($PlaylistFile->file(), '8bit')); break; case 'wpl': $PlaylistFile->CreateWPLList($items, false); $PlaylistFile->setHeader($playlistFileName, 'application/vnd.ms-wpl', mb_strlen($PlaylistFile->file(), '8bit')); break; case 'plist': // Placeholder for Apples plist break; default: $PlaylistFile->CreateM3UList($items, false); $PlaylistFile->setHeader($playlistFileName, 'audio/x-mpegurl', mb_strlen($PlaylistFile->file(), '8bit')); break; } $PlaylistFile->send($PlaylistFile->file()); }
function check() { if (empty($this->alias)) { $this->alias = $this->title; } $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S"); } return true; }
public static function getAliasName($alias) { $alias = JApplication::stringURLSafe($alias); if (trim(str_replace('-', '', $alias)) == '') { $alias = JFactory::getDate()->format("Y-m-d-H-i-s"); } return $alias; }
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(' ', '', $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; }