/** * Installs a new theme * * @since 1.0 * @access public * @param string * @return */ public function install($file) { $source = $file['tmp_name']; $fileName = md5($file['name'] . Foundry::date()->toMySQL()); $fileExtension = '_themes_install.zip'; $destination = JPATH_ROOT . '/tmp/' . $fileName . $fileExtension; // Upload the zip archive $state = JFile::upload($source, $destination); if (!$state) { $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_COPY_FROM_PHP')); return false; } // Extract the zip $extracted = dirname($destination) . '/' . $fileName . '_themes_install'; $state = JArchive::extract($destination, $extracted); // Once it is extracted, delete the zip file JFile::delete($destination); // Get the configuration file. $manifest = $extracted . '/config/template.json'; $manifest = JFile::read($manifest); // Get the theme object $theme = json_decode($manifest); // Move it to the appropriate folder $themeDestination = EBLOG_THEMES . '/' . strtolower($theme->element); $exists = JFolder::exists($themeDestination); // If folder exists, overwrite it. For now, just throw an error. if ($exists) { // Delete teh etracted folder JFolder::delete($extracted); $this->setError(JText::sprintf('COM_EASYBLOG_THEMES_INSTALLER_ERROR_SAME_THEME_FOLDER_EXISTS', $theme->element)); return false; } // Move extracted folder $state = JFolder::move($extracted, $themeDestination); if (!$state) { // Delete the etracted folder JFolder::delete($extracted); $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_MOVING_FOLDER_TO_THEMES_FOLDER')); return false; } return true; }
/** * Renders a date form * * @since 1.0 * @access public * @param string The key name for the input. * @param string The date value. * @param string The id of the date form. (optional, will fallback to name by default) * @param string/array The attributes to add to the select list. * * @return string The html output. * * @author Jason Rey <*****@*****.**> */ public static function dateform($name, $value = '', $id = '', $attributes = '', $withOffset = true) { if (is_array($attributes)) { $attributes = implode(' ', $attributes); } if (empty($value)) { $value = Foundry::date('now', $withOffset); } else { $value = Foundry::date($value, $withOffset); } $theme = Foundry::get('Themes'); $theme->set('name', $name); $theme->set('value', $value); $theme->set('id', $id); $theme->set('attributes', $attributes); return $theme->output('admin/html/grid.dateform'); }
public function injectLike( $comment ) { if( !$this->exists() ) { return false; } if( !empty( $comment->params->social->stream ) ) { $likeTable = Foundry::table( 'likes' ); $liked = $likeTable->load( array( 'type' => 'komento.user', 'uid' => $comment->params->social->stream, 'created_by' => Foundry::user()->id ) ); if( !$liked ) { $likeTable->type = 'komento.user'; $likeTable->uid = $comment->params->social->stream; $likeTable->created_by = Foundry::user()->id; $likeTable->created = Foundry::date()->toSQL(); $state = $likeTable->store(); } } }