public static function renderAllCSS($noBootStrap = 0) { $app = JFactory::getApplication(); $itemid = $app->input->get('Itemid', 0, 'int'); $db = JFactory::getDBO(); $query = 'SELECT a.filename as filename, a.type as type, a.menulink as menulink' .' FROM #__phocadownload_styles AS a' .' WHERE a.published = 1' .' ORDER BY a.type, a.ordering ASC'; $db->setQuery($query); $filenames = $db->loadObjectList(); if (!empty($filenames)) { foreach ($filenames as $fk => $fv) { $path = PhocaDownloadFile::getCSSPath($fv->type, 1); if ($fv->menulink != '' && (int)$fv->menulink > 1) { $menuLinks = explode(',', $fv->menulink); $isIncluded = in_array((int)$itemid, $menuLinks); if ($isIncluded) { JHtml::stylesheet($path . $fv->filename ); } } else { JHtml::stylesheet($path . $fv->filename ); } } } }
public function save($data) { jimport('joomla.filesystem.file'); // New if ($data['id'] < 1) { $data['type'] = 2;// Custom in every case if ($data['title'] != '') { $filename = JApplication::stringURLSafe($data['title']); if (trim(str_replace('-','',$filename)) == '') { $filename = JFactory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S"); } } else { $filename = JFactory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S"); } $filename = $filename . '.css'; $data['filename'] = $filename; $filePath = PhocaDownloadFile::existsCSS($filename, $data['type']); if ($filePath) { $this->setError(JText::sprintf('COM_PHOCADOWNLOAD_FILE_ALREADY_EXISTS', $fileName)); return false; } else { $filePath = PhocaDownloadFile::getCSSPath($data['type']) . $filename; } } else { $filename = PhocaDownloadFile::getCSSFile($data['id']); $filePath = PhocaDownloadFile::existsCSS($filename, $data['type']); } //$dispatcher = JEventDispatcher::getInstance(); $fileName = $filename; // Include the extension plugins for the save events. //JPluginHelper::importPlugin('extension'); // Set FTP credentials, if given. JClientHelper::setCredentialsFromRequest('ftp'); $ftp = JClientHelper::getCredentials('ftp'); // Try to make the template file writeable. if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0644')) { $this->setError(JText::_('COM_PHOCADOWNLOAD_ERROR_SOURCE_FILE_NOT_WRITABLE')); return false; } // Trigger the onExtensionBeforeSave event. /*$result = $dispatcher->trigger('onExtensionBeforeSave', array('com_phocadownload.source', &$data, false)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; }*/ $return = JFile::write($filePath, $data['source']); // Try to make the template file unwriteable. if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0444')) { $this->setError(JText::_('COM_PHOCADOWNLOAD_ERROR_SOURCE_FILE_NOT_UNWRITABLE')); return false; } elseif (!$return) { $this->setError(JText::sprintf('COM_PHOCADOWNLOAD_ERROR_FAILED_TO_SAVE_FILENAME', $fileName)); return false; } // Trigger the onExtensionAfterSave event. //$dispatcher->trigger('onExtensionAfterSave', array('com_templates.source', &$table, false)); //return true; return parent::save($data); }