I'm using Netbeans for my C++ programming.
Would like to create the following code template for C++ source file and header file:
/**
* Name: %<%NAME%>%.%<%EXTENSION%>%
* Author(s): %<%USER%>%
* Date: %<%DATE%>%
* Revision: 1.0
*/
Above NAME, EXTENSION, USER and DATE are default code templates provided by Netbeans. Where do I find this list in Netbeans? Also, the default result of DATE is MMM DD, YYYY format, e.g. February 29, 2012. Is it possible to customize the format to DD-MMM-YYYY (e.g. 29-Feb-2012)?
The following works for PHP, it should be the same in C++.
<?php
<#assign licenseFirst = "/** ">
<#assign licensePrefix = " * ">
<#assign licenseLast = "*---------------------------------------------------- ">
<#include "../Licenses/license-${project.license}.txt">
* ${date}
* File: ${nameAndExt}
* Encoding: ${encoding}
* Project: ${project.displayName}
*
* Author: Rob Haag :: rob#mydomain.com
*
**/
?>
Reference
Related
I am making a webservice using TYPO3. Everything in the frontend should be JSON with HTTP header Content-Type: application/json, however I am unable to change the Content-Type header for the 404 page. Whatever I try, it's always Content-Type: text/html; charset=utf-8. How can I change this?
This is my basic page TypoScript configuration:
page = PAGE
page {
config {
disableAllHeaderCode = 1
disablePrefixComment = 1
xhtml_cleaning = 0
admPanel = 0
}
10 = USER
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = MyExt
pluginName = MyPlugin
vendorName = MyVendor
}
}
The extension uses TYPO3\CMS\Extbase\Mvc\View\JsonView.
I've already tried adding the header using config.additionalHeaders.10.header = Content-Type: application/json. I've also tried setting [FE][pageNotFound_handling] to USER_FUNCTION:... and setting the headers in PHP.
I found the solution myself. From TYPO3 9.5 the default page not found handling can be overridden in the site configuration:
errorHandling:
-
errorCode: 404
errorHandler: PHP
errorPhpClassFQCN: Vendor\MyExt\PageErrorHandler\PageNotFoundHandler
And in EXT:MyExt/Classes/PageErrorHandler/PageNotFoundHandler.php:
<?php
namespace Vendor\MyExt\PageErrorHandler;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
/**
* Class PageNotFoundHandler
*/
class PageNotFoundHandler implements PageErrorHandlerInterface
{
/**
* Handle page error
*
* #param ServerRequestInterface $request
* #param string $message
* #param array $reasons
* #return ResponseInterface
*/
public function handlePageError(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface
{
$response = new Response(404, ['Content-Type' => 'application/json'], '{"error":"Not found"}');
return $response;
}
}
I'm trying to use doxygen, breathe and sphinx to generate documentation for a C# library. This is under Windows. The basic directory structure is:
docs
index.rst
conf.py
xml
xml output from doxygen
I'm running into the following error when I execute make.bat html:
C:\Programming\J4JLogging\J4JLogging\docs\index.rst:25: WARNING: doxygeninterface: Cannot find class "IJ4JLoggerConfiguration" in doxygen xml output for project "J4JLogger" from directory: ./xml
Here's the contents of conf.py
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
project = 'J4JLogger'
copyright = '2019, Mark Olbert'
author = 'Mark Olbert'
extensions = [ "breathe" ]
breathe_projects = {
"J4JLogger": "./xml"
}
breathe_default_project = "J4JLogger"
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
and here's the contents of index.rst:
.. J4JLogger documentation master file, created by
sphinx-quickstart on Tue Jun 11 16:33:34 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to J4JLogger's documentation!
=====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Docs
====
.. doxygeninterface:: IJ4JLoggerConfiguration
:members:
The contents of the xml folder created by doxygen looks like this:
I try to generate a csv-file in my TYPO3 Extension. I get following error:
1225709595: The Fluid template files "" could not be loaded. (More information)
TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException thrown in file
/usr/local/www/apache24/xx/xx/vendor/typo3fluid/fluid/src/View/TemplatePaths.php in line 719.
25 TYPO3Fluid\Fluid\View\TemplatePaths::resolveFileInPaths(array, "Default", "csv")
My Controller looks like:
$icalView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$icalView->setFormat('csv');
$icalView->setTemplatePathAndFilename('typo3conf/ext/xxx/Resources/Private/Templates/Bestellung/Listbestellungen.txt');
$icalView->assign('xx', $xx);
$icalContent = $icalView->render();
I do have Subfolter "Layout" in ... Bestellung/ and I do have file Default.csv
Same code working in extension in TYPO3 7.6.x - what has changed in 8.7?
Thanks for help!
Martin
Here an snippet how I do it in 8.7 to send an eMail:
As I know you have to set the paths for Template, Layout and Partials also, before you select the template to use
/**
* configurationManager
*
* #var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager
* #inject
*/
protected $configurationManager;
public function sendEmail($template,...)
{
/**
* Generate Email Body
*/
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
/** #var StandaloneView $emailView */
$emailView = $this->objectManager->get(StandaloneView::class);
$emailView->getRequest()->setControllerExtensionName($controllerExtensionName);
$emailView->getRequest()->setPluginName($pluginName);
$emailView->getRequest()->setControllerName($controllerName);
$emailView->setTemplateRootPaths($extbaseFrameworkConfiguration['view']['templateRootPaths']);
$emailView->setLayoutRootPaths($extbaseFrameworkConfiguration['view']['layoutRootPaths']);
$emailView->setPartialRootPaths($extbaseFrameworkConfiguration['view']['partialRootPaths']);
$emailView->setTemplate('Email/' . ucfirst($template));
$emailView->assignMultiple($variables);
$emailBody = $emailView->render();
}
I solved this by changing the code a little bit and now it is working:
$storage = $this->resourceFactory->getDefaultStorage();
if ($storage === NULL) {
throw new \RuntimeException('Could not get the default storage', 1475590001);
}
/** #var \TYPO3\CMS\Fluid\View\StandaloneView $icalView */
$icalView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$icalView->setFormat('csv');
$templateRootPath[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Templates/');
$layoutRootPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Layouts/');
$partialRootPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Partials/');
$icalView->setLayoutRootPaths($layoutRootPaths);
$icalView->setPartialRootPaths($partialRootPaths);
$icalView->setTemplatePathAndFilename('typo3conf/ext/xxx/Resources/Private/Templates/Bestellung/Listbestellungen.txt');
$icalView->assign('xxx', $xxx);
$icalContent = $icalView->render();
$tempFolder = $storage->getFolder('bestellungencsv');
$tempFile = $storage->createFile('bestellungen_'.$xxx->getUid().'.csv', $tempFolder);
$tempFile->setContents($icalContent);
I am running Magento v.1.9.0.1 and I am facing a problem with the dates displayed when editing a customer via the admin area. For example,
Last Logged In: 11 Feb 7791 4:23:48 μ.μ.
Last Logged In (Europe/Istanbul): 09 Feb 2015 3:16:31 μ.μ.
Account Created on: 02 Sep 2015 4:16:11 μ.μ.
The client registered on the 9th of February 2015. I searched around and found topics about other Magento versions that said for some dates Magento is swapping the dates, hence the difference between actual created date (09/02/2015) and reported created date (02/09/2015).
I couldn't find anything about version 1.9 nor anything about the year reported for last logged in (7791!).
Is there a fix for this problem?
Thank you for your time.
Faced same issue in Magento 1.8.1 , and applied below solution for account created date and last login date.Because some how Magento is converting day to month and month to date in customer edit section.
Path : app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tab\View.php
Override below methods from above file :
public function getCreateDate()
{
$cutomerId = $this->getRequest()->getParam('id');
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$select = $connection->select()
->from('customer_entity', array('created_at'))
->where('entity_id=?',$cutomerId);
$rowArray = $connection->fetchRow($select);
return $this->_getCoreHelper()->formatDate($rowArray['created_at'],
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
}
public function getStoreCreateDate()
{
$cutomerId = $this->getRequest()->getParam('id');
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$select = $connection->select()
->from('customer_entity', array('created_at'))
->where('entity_id=?',$cutomerId);
$rowArray = $connection->fetchRow($select);
return $this->_getCoreHelper()->formatDate($rowArray['created_at'],
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
}
public function getLastLoginDate()
{
if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
$date = Mage::app()->getLocale()->storeDate(
$this->getCustomer()->getStoreId(),
$date,
true
);
return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
}
return Mage::helper('customer')->__('Never');
}
I have also faced the same issue for quite a long time till i found the solution http://www.customerparadigm.com/magento-bug-magento-customer-create-date-juxtaposition/
Summary of the files in the Magento Extension for solving the Magento Date Switch Fix:
Created.php:
app/code/local/CustomerParadigm/Datefix/Model/Entity/Attribute/Backend/Time/Created.php
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magento.com so we can send you a copy immediately.
*
// * DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* #category Mage
* #package Mage_Eav
* #copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
* #license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Entity/Attribute/Model - attribute backend default
*
* #category Mage
* #package Mage_Eav
* #author Magento Core Team <core#magentocommerce.com>
*/
class CustomerParadigm_Datefix_Model_Entity_Attribute_Backend_Time_Created extends Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
{
/**
* Returns date format if it matches a certain mask.
* #param $date
* #return null|string
*/
/* This shouldn't be needed for the datetime switch bug fix. Removing for testing.
protected function _getFormat($date)
{
if (is_string($date) && preg_match('#^\d{4,4}-\d{2,2}-\d{2,2} \d{2,2}:\d{2,2}:\d{2,2}$#', $date)) {
return 'yyyy-MM-dd HH:mm:ss';
}
return null;
}
*/
/**
* Set created date
* Set created date in UTC time zone
*
* #param Mage_Core_Model_Object $object
* #return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$date = $object->getData($attributeCode);
if (is_null($date)) {
if ($object->isObjectNew()) {
$object->setData($attributeCode, Varien_Date::now());
}
} else {
// Date switch fix
$date = strtotime($date);
// convert to UTC
$zendDate = Mage::app()->getLocale()->utcDate(null, $date, true);
$object->setData($attributeCode, $zendDate->getIso());
}
return $this;
}
/**
* Convert create date from UTC to current store time zone
*
* #param Varien_Object $object
* #return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
*/
public function afterLoad($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$date = $object->getData($attributeCode);
// Date switch fix
if (!is_null($date)) {
$date = strtotime($date);
}
$zendDate = Mage::app()->getLocale()->storeDate(null, $date, true);
$object->setData($attributeCode, $zendDate->getIso());
parent::afterLoad($object);
return $this;
}
}
app/code/local/CustomerParadigm/Datefix/etc/config.xml
<config>
<global>
<models>
<eav>
<rewrite>
<entity_attribute_backend_time_created>CustomerParadigm_Datefix_Model_Entity_Attribute_Backend_Time_Created</entity_attribute_backend_time_created>
</rewrite>
</eav>
</models>
</global>
</config>
/app/etc/module/ CustomerParadigm_Datefix.xml
<?xml version=”1.0″?>
<config>
<modules>
<CustomerParadigm_Datefix>
<active>true</active>
<codePool>local</codePool>
</CustomerParadigm_Datefix>
</modules>
</config>
I am not having much reputation to comment, so pointing out through a response:
#Digisha: You have mentioned this for getLastLoginDate()
public function getLastLoginDate()
{
if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
$date = Mage::app()->getLocale()->storeDate(
$this->getCustomer()->getStoreId(),
$date,
true
);
return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
}
return Mage::helper('customer')->__('Never');
}
I just want to ask if this is correct parameter for if condition:
if ($date = $this->getCustomerLog()->getLoginAtTimestamp())
I don't think so, you are assinging and then how is this correct??
Is there a relatively simple way in nant, without writing a custom task, to get the name of the newest folder in a certain directory? Recursion is not needed. I have been trying to do it with directory::get-creation-time and a foreach loop and if statements, yada yada. It's too complex, and I'm about to create a custom task instead. However, I suspect there is some simpler way to do it via existing nant features.
I believe you're correct in stating that doing this in a pure nant fashion might pose to be messy, especially the way properties work in nant. If you don't want to write a custom task, you can always use the script task. For example:
<?xml version="1.0"?>
<project name="testing" basedir=".">
<script language="C#" prefix="test" >
<code>
<![CDATA[
[Function("find-newest-dir")]
public static string FindNewestDir( string startDir ) {
string theNewestDir = string.Empty;
DateTime theCreateTime = new DateTime();
DateTime theLastCreateTime = new DateTime();
string[] theDirs = Directory.GetDirectories( startDir );
for ( int theCurrentIdx = 0; theCurrentIdx < theDirs.Length; ++theCurrentIdx )
{
if ( theCurrentIdx != 0 )
{
DateTime theCurrentDirCreateTime = Directory.GetCreationTime( theDirs[ theCurrentIdx ] );
if ( theCurrentDirCreateTime >= theCreateTime )
{
theNewestDir = theDirs[ theCurrentIdx ];
theCreateTime = theCurrentDirCreateTime;
}
}
else
{
theNewestDir = theDirs[ theCurrentIdx ];
theCreateTime = Directory.GetCreationTime( theDirs[ theCurrentIdx ] );
}
}
return theNewestDir;
}
]]>
</code>
</script>
<property name="dir" value="" overwrite="false"/>
<echo message="The newest directory is: ${test::find-newest-dir( dir )}"/>
</project>
With this, one should be able to call the function to get the newest directory. The implementation of the actual function could be changed to be anything (optimized a bit more or whatever), but I've included a quick one for reference on how to use the script task. It produces output like the following:
nant -D:dir=c:\
NAnt 0.85 (Build 0.85.2478.0; release; 10/14/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///C:/tmp/NAnt.build
Target framework: Microsoft .NET Framework 2.0
[script] Scanning assembly "jdrgmbuy" for extensions.
[echo] The newest directory is: C:\tmp
BUILD SUCCEEDED
Total time: 0.3 seconds.