本文整理汇总了PHP中CrowdfundingHelper类的典型用法代码示例。如果您正苦于以下问题:PHP CrowdfundingHelper类的具体用法?PHP CrowdfundingHelper怎么用?PHP CrowdfundingHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CrowdfundingHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tpl = null)
{
$this->option = JFactory::getApplication()->input->getCmd('option');
$container = Prism\Container::getContainer();
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
// Get params
$this->params = $this->state->get('params');
/** @var $this->params Joomla\Registry\Registry */
$this->numberInRow = (int) $this->params->get('featured_items_row', 3);
$helperBus = new Prism\Helper\HelperBus($this->items);
$helperBus->addCommand(new Crowdfunding\Helper\PrepareItemsHelper());
$helperBus->handle();
$this->displayCreator = (bool) $this->params->get('integration_display_creator', true);
// Prepare integration. Load avatars and profiles.
if ($this->displayCreator) {
$userIds = Prism\Utilities\ArrayHelper::getIds($this->items, 'user_id');
$this->socialProfiles = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $userIds);
}
$this->layoutData = new stdClass();
$this->layoutData->items = $this->items;
$this->layoutData->params = $this->params;
$this->layoutData->money = $this->getMoneyFormatter($container, $this->params);
$this->layoutData->socialProfiles = $this->socialProfiles;
$this->layoutData->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
$this->prepareDocument();
parent::display($tpl);
}
示例2: addSidebar
/**
* Add a menu on the sidebar of page
*/
protected function addSidebar()
{
// Add submenu
CrowdfundingHelper::addSubmenu($this->getName());
JHtmlSidebar::setAction('index.php?option=' . $this->option . '&view=' . $this->getName());
$this->sidebar = JHtmlSidebar::render();
}
示例3: loadFormData
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
* @since 1.6
*/
protected function loadFormData()
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
$data = $app->getUserState($this->option . '.edit.funding.data', array());
if (!$data) {
$itemId = (int) $this->getState($this->getName() . '.id');
$userId = JFactory::getUser()->get("id");
$data = $this->getItem($itemId, $userId);
// Prepare date format.
$dateFormat = CrowdfundingHelper::getDateFormat();
$dateValidator = new Prism\Validator\Date($data->funding_end);
// Validate end date. If the date is not valid, generate a valid one.
// Use minimum allowed days to generate end funding date.
if (!$dateValidator->isValid()) {
// Get minimum days.
$params = $this->getState("params");
$minDays = $params->get("project_days_minimum", 30);
// Generate end date.
$today = new Crowdfunding\Date();
$fundingEndDate = $today->calculateEndDate($minDays);
$data->funding_end = $fundingEndDate->format("Y-m-d");
}
$date = new JDate($data->funding_end);
$data->funding_end = $date->format($dateFormat);
}
return $data;
}
示例4: onBeforeDelete
/**
* Pre-processor for $table->delete($pk)
*
* @param mixed $pk An optional primary key value to delete. If not set the instance property value is used.
*
* @return void
*
* @since 3.1.2
* @throws UnexpectedValueException
*/
public function onBeforeDelete($pk)
{
$userId = CrowdfundingHelper::getUserIdByRewardId($this->table->id);
$imagesFolder = CrowdfundingHelper::getImagesFolder($userId);
// Remove image.
if (!empty($this->table->image)) {
$fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image;
if (JFile::exists($fileSource)) {
JFile::delete($fileSource);
}
}
// Remove thumbnail.
if (!empty($this->table->image_thumb)) {
$fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image_thumb;
if (JFile::exists($fileSource)) {
JFile::delete($fileSource);
}
}
// Remove square image.
if (!empty($this->table->image_square)) {
$fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image_square;
if (JFile::exists($fileSource)) {
JFile::delete($fileSource);
}
}
}
示例5: display
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->form = $this->get('Form');
$this->importType = $this->state->get("import.context");
switch ($this->importType) {
case "locations":
$this->legend = JText::_("COM_CROWDFUNDING_IMPORT_LOCATIONS_DATA");
$this->uploadTask = "import.locations";
break;
case "countries":
$this->legend = JText::_("COM_CROWDFUNDING_IMPORT_COUNTRIES_DATA");
$this->uploadTask = "import.countries";
break;
case "states":
$this->legend = JText::_("COM_CROWDFUNDING_IMPORT_STATES_DATA");
$this->uploadTask = "import.states";
break;
default:
// Currencies
$this->legend = JText::_("COM_CROWDFUNDING_IMPORT_CURRENCY_DATA");
$this->uploadTask = "import.currencies";
break;
}
// Add submenu
CrowdfundingHelper::addSubmenu($this->importType);
// Prepare actions
$this->addToolbar();
$this->setDocument();
parent::display($tpl);
}
示例6: display
public function display($tpl = null)
{
$this->option = JFactory::getApplication()->input->getCmd('option');
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
// Get params
$this->params = $this->state->get('params');
/** @var $this->params Joomla\Registry\Registry */
$this->numberInRow = (int) $this->params->get('featured_items_row', 3);
$this->items = CrowdfundingHelper::prepareItems($this->items, $this->numberInRow);
// Get the folder with images
$this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
// Get currency
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency'));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
$this->displayCreator = (bool) $this->params->get('integration_display_creator', true);
// Prepare integration. Load avatars and profiles.
if ($this->displayCreator) {
$socialProfilesBuilder = new Prism\Integration\Profiles\Builder(array('social_platform' => $this->params->get('integration_social_platform'), 'users_ids' => CrowdfundingHelper::fetchUserIds($this->items)));
$socialProfilesBuilder->build();
$this->socialProfiles = $socialProfilesBuilder->getProfiles();
}
$this->layoutData = array('items' => $this->items, 'params' => $this->params, 'amount' => $this->amount, 'socialProfiles' => $this->socialProfiles, 'imageFolder' => $this->imageFolder, 'titleLength' => $this->params->get('discover_title_length', 0), 'descriptionLength' => $this->params->get('discover_description_length', 0), 'span' => $this->numberInRow > 0 ? round(12 / $this->numberInRow) : 4);
$this->prepareDocument();
parent::display($tpl);
}
示例7: display
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->params = $this->state->get("params");
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->state->params->get("project_currency"));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
// Get rewards number
$usersIds = array();
foreach ($this->items as $item) {
$usersIds[] = $item->id;
}
// Get number of rewards.
$statistics = new Crowdfunding\Statistics\Users(JFactory::getDbo(), $usersIds);
$this->projects = $statistics->getProjectsNumber();
$this->amounts = $statistics->getAmounts();
// Add submenu
CrowdfundingHelper::addSubmenu($this->getName());
// Prepare sorting data
$this->prepareSorting();
// Prepare actions
$this->addToolbar();
$this->addSidebar();
$this->setDocument();
parent::display($tpl);
}
示例8: display
public function display($tpl = null)
{
$this->option = JFactory::getApplication()->input->getCmd('option');
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->params = $this->state->get('params');
$this->numberInRow = (int) $this->params->get('items_row', 3);
$this->prepareItems($this->items);
// Get the folder with images
$this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
// Get currency
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency'));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
$this->displayCreator = (bool) $this->params->get('display_creator', true);
// Prepare social integration.
if ($this->displayCreator !== false) {
$usersIds = CrowdfundingHelper::fetchIds($this->items, 'user_id');
$this->socialProfiles = CrowdfundingHelper::prepareIntegrations($this->params->get('integration_social_platform'), $usersIds);
}
$this->layoutData = array('items' => $this->items, 'params' => $this->params, 'amount' => $this->amount, 'socialProfiles' => $this->socialProfiles, 'imageFolder' => $this->imageFolder, 'titleLength' => $this->params->get('discover_title_length', 0), 'descriptionLength' => $this->params->get('discover_description_length', 0), 'span' => $this->numberInRow > 0 ? round(12 / $this->numberInRow) : 4);
$this->prepareDocument();
parent::display($tpl);
}
示例9: display
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->params = $this->state->get("params");
// Get currencies
$currencies = array();
foreach ($this->items as $item) {
$currencies[] = $item->txn_currency;
}
$currencies = array_unique($currencies);
if (!empty($currencies)) {
$options = new Joomla\Registry\Registry();
$options->set("locale_intl", $this->params->get("locale_intl"));
$options->set("amount_format", $this->params->get("amount_format"));
$this->currencies = new Crowdfunding\Currencies(JFactory::getDbo(), $options);
$this->currencies->loadByCode($currencies);
}
$this->amount = new Crowdfunding\Amount($this->params);
// Get enabled specefic plugins.
$extensions = new Prism\Extensions(JFactory::getDbo(), $this->specificPlugins);
$this->enabledSpecificPlugins = $extensions->getEnabled();
// Add submenu
CrowdfundingHelper::addSubmenu($this->getName());
// Prepare sorting data
$this->prepareSorting();
// Prepare actions
$this->addToolbar();
$this->addSidebar();
$this->setDocument();
parent::display($tpl);
}
示例10: display
public function display($tpl = null)
{
// Initialise variables
$this->state = $this->get("State");
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
// Get params
$this->params = $this->state->get("params");
/** @var $this->params Joomla\Registry\Registry */
$this->numberInRow = $this->params->get("items_row", 3);
$this->items = CrowdfundingHelper::prepareItems($this->items, $this->numberInRow);
// Get the folder with images
$this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
// Get currency
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency"));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
$this->displayCreator = $this->params->get("integration_display_creator", true);
// Prepare social integration.
if (!empty($this->displayCreator)) {
$socialProfilesBuilder = new Prism\Integration\Profiles\Builder(array("social_platform" => $this->params->get("integration_social_platform"), "users_ids" => CrowdfundingHelper::fetchUserIds($this->items)));
$socialProfilesBuilder->build();
$this->socialProfiles = $socialProfilesBuilder->getProfiles();
}
$this->layoutData = array("items" => $this->items, "params" => $this->params, "amount" => $this->amount, "socialProfiles" => $this->socialProfiles, "imageFolder" => $this->imageFolder, "titleLength" => $this->params->get("discover_title_length", 0), "descriptionLength" => $this->params->get("discover_description_length", 0), "span" => !empty($this->numberInRow) ? round(12 / $this->numberInRow) : 4);
$this->prepareDocument();
parent::display($tpl);
}
示例11: onAfterDispatch
public function onAfterDispatch()
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
if ($app->isAdmin()) {
return;
}
$document = JFactory::getDocument();
/** @var $document JDocumentHtml */
$type = $document->getType();
if (strcmp('html', $type) !== 0) {
return;
}
// It works only for GET and POST requests.
$method = strtolower($app->input->getMethod());
if (!in_array($method, array('get', 'post'), true)) {
return;
}
// Check component enabled
if (!JComponentHelper::isEnabled('com_crowdfunding')) {
return;
}
$view = $app->input->getCmd('view');
$option = $app->input->getCmd('option');
$isCrowdfundingComponent = strcmp($option, 'com_crowdfunding') === 0;
$isDetailsPage = (strcmp($option, 'com_crowdfunding') === 0 and strcmp($view, 'details') === 0);
// Allowed views for the module Crowdfunding Details
$allowedViewsModuleDetails = array('backing', 'embed', 'report', 'friendmail');
$allowedViewsModuleFilters = array('discover', 'category');
// Hide some modules if it is not details page.
if (!$isDetailsPage) {
$this->hideModule('mod_crowdfundinginfo');
$this->hideModule('mod_crowdfundingprofile');
$this->hideModule('mod_crowdfundingreporting');
}
// Module Crowdfunding Rewards (mod_crowdfundingrewards).
if (!$isDetailsPage) {
$this->hideModule('mod_crowdfundingrewards');
} else {
// Check project type. If the rewards are disable, hide the module.
$projectId = $app->input->getInt('id');
if ($projectId > 0 and !CrowdfundingHelper::isRewardsEnabled($projectId)) {
// Hide the module Crowdfunding Rewards, if rewards are disabled.
$this->hideModule('mod_crowdfundingrewards');
}
}
// Module Crowdfunding Details (mod_crowdfundingdetails) on backing and embed pages.
if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleDetails, true)) {
$this->hideModule('mod_crowdfundingdetails');
}
// Module Crowdfunding Filters (mod_crowdfundingfilters).
if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleFilters, true)) {
$this->hideModule('mod_crowdfundingfilters');
}
// Module Crowdfunding Filters (mod_crowdfundingsearch).
if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleFilters, true)) {
$this->hideModule('mod_crowdfundingsearch');
}
}
示例12: addSidebar
/**
* Add a menu on the sidebar of page
*/
protected function addSidebar()
{
// Add submenu
CrowdfundingHelper::addSubmenu('projects');
JHtmlSidebar::setAction('index.php?option=' . $this->option . '&view=' . $this->getName());
JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('archived' => false)), 'value', 'text', $this->state->get('filter.state'), true));
$this->sidebar = JHtmlSidebar::render();
}
示例13: onAfterDispatch
public function onAfterDispatch()
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
if ($app->isAdmin()) {
return;
}
$document = JFactory::getDocument();
/** @var $document JDocumentHtml */
$type = $document->getType();
if (strcmp("html", $type) != 0) {
return;
}
// It works only for GET and POST requests.
$method = JString::strtolower($app->input->getMethod());
if (!in_array($method, array("get", "post"))) {
return;
}
// Check component enabled
if (!JComponentHelper::isEnabled('com_crowdfunding', true)) {
return;
}
$view = $app->input->getCmd("view");
$option = $app->input->getCmd("option");
$isCrowdfundingComponent = strcmp($option, "com_crowdfunding") == 0;
$isDetailsPage = (strcmp($option, "com_crowdfunding") == 0 and strcmp($view, "details") == 0);
// Allowed views for the module Crowdfunding Details
$allowedViewsModuleDetails = array("backing", "embed", "report");
$allowedViewsModuleFilters = array("discover", "category");
// Hide some modules if it is not details page.
if (!$isDetailsPage) {
$this->hideModule("mod_crowdfundinginfo");
$this->hideModule("mod_crowdfundingprofile");
$this->hideModule("mod_crowdfundingreporting");
}
// Module Crowdfunding Rewards (mod_crowdfundingrewards).
if (!$isDetailsPage) {
$this->hideModule("mod_crowdfundingrewards");
} else {
// Check project type. If the rewards are disable, hide the module.
$projectId = $app->input->getInt("id");
if (!empty($projectId)) {
// Hide the module Crowdfunding Rewards, if rewards are disabled.
if (!CrowdfundingHelper::isRewardsEnabled($projectId)) {
$this->hideModule("mod_crowdfundingrewards");
}
}
}
// Module Crowdfunding Details (mod_crowdfundingdetails) on backing and embed pages.
if (!$isCrowdfundingComponent or strcmp($option, "com_crowdfunding") == 0 and !in_array($view, $allowedViewsModuleDetails)) {
$this->hideModule("mod_crowdfundingdetails");
}
// Module Crowdfunding Filters (mod_crowdfundingfilters).
if (!$isCrowdfundingComponent or strcmp($option, "com_crowdfunding") == 0 and !in_array($view, $allowedViewsModuleFilters)) {
$this->hideModule("mod_crowdfundingfilters");
}
}
示例14: loadFormData
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState($this->option . '.edit.report.data', array());
if (empty($data)) {
$data = $this->getItem();
$data->title = CrowdfundingHelper::getProjectTitle($data->project_id);
}
return $data;
}
示例15: save
public function save($key = null, $urlVar = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$data = $this->input->post->get('jform', array(), 'array');
$itemId = JArrayHelper::getValue($data, "id");
$redirectOptions = array("task" => $this->getTask(), "id" => $itemId);
// Parse formatted goal and funded amounts.
$data["goal"] = CrowdfundingHelper::parseAmount($data["goal"]);
$data["funded"] = CrowdfundingHelper::parseAmount($data["funded"]);
$model = $this->getModel();
/** @var $model CrowdfundingModelProject */
$form = $model->getForm($data, false);
/** @var $form JForm */
if (!$form) {
throw new Exception(JText::_("COM_Crowdfunding_ERROR_FORM_CANNOT_BE_LOADED"), 500);
}
// Validate the form
$validData = $model->validate($form, $data);
$validData["duration_type"] = JArrayHelper::getValue($data, "funding_duration_type");
// Check for errors.
if ($validData === false) {
$this->displayNotice($form->getErrors(), $redirectOptions);
return;
}
try {
// Get image
$files = $this->input->files->get('jform', array(), 'array');
$image = JArrayHelper::getValue($files, "image");
$pitchImage = JArrayHelper::getValue($files, "pitch_image");
// Upload image
if (!empty($image['name'])) {
$imageNames = $model->uploadImage($image);
if (!empty($imageNames["image"])) {
$validData = array_merge($validData, $imageNames);
}
}
// Upload pitch image
if (!empty($pitchImage['name'])) {
$pitchImageName = $model->uploadPitchImage($pitchImage);
if (!empty($pitchImageName)) {
$validData["pitch_image"] = $pitchImageName;
}
}
$itemId = $model->save($validData);
$redirectOptions["id"] = $itemId;
} catch (Exception $e) {
JLog::add($e->getMessage());
throw new Exception(JText::_('COM_Crowdfunding_ERROR_SYSTEM'));
}
$this->displayMessage(JText::_('COM_Crowdfunding_PROJECT_SAVED'), $redirectOptions);
}