本文整理汇总了PHP中Varien_Date类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Date类的具体用法?PHP Varien_Date怎么用?PHP Varien_Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Date类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _create
protected function _create(array $data)
{
try {
if (!empty($data)) {
foreach ($data['items'] as $cmsblocks) {
$storeArray = array();
$storeArray = explode(',', $cmsblocks['store_ids']);
$identifier = trim($cmsblocks['identifier']);
$cmsBlock = Mage::getModel('cms/block');
$collection = Mage::getModel('cms/block')->getCollection()->addStoreFilter($storeArray, false)->addFieldToFilter('identifier', $identifier);
//->toArray();
$collectionData = $collection->getData();
if (isset($collectionData[0]['block_id'])) {
$cmsBlock->load($collectionData[0]['block_id']);
}
if ($cmsBlock->isObjectNew()) {
$cmsBlock->setIdentifier($identifier)->setCreationTime(Varien_Date::now());
}
$cmsBlock->setUpdateTime(Varien_Date::now())->setStores(array($cmsblocks['store_ids']))->setIsActive($cmsblocks['is_active'])->setTitle($cmsblocks['title'])->setContent($cmsblocks['content'])->save();
}
} else {
$this->_critical('Empty data found');
}
} catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
$this->_critical(sprintf('Invalid attribute "%s": %s', $e->getAttributeCode(), $e->getMessage()), Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
} catch (Mage_Core_Exception $e) {
$this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
} catch (Exception $e) {
$this->_critical(self::RESOURCE_UNKNOWN_ERROR);
}
}
开发者ID:brentwpeterson,项目名称:magento-cms-update-api,代码行数:31,代码来源:V1.php
示例2: _create
protected function _create(array $data)
{
try {
if (!empty($data)) {
foreach ($data['items'] as $cmspages) {
$identifier = trim($cmspages['identifier']);
$cmsPage = Mage::getModel('cms/page');
$cmsCheck = $cmsPage->getResource()->checkIdentifier($identifier, $cmspages['store_ids']);
if ($cmsCheck) {
$cmsPage->load($cmsCheck);
}
if ($cmsPage->isObjectNew()) {
$cmsPage->setIdentifier($identifier)->setCreationTime(Varien_Date::now());
}
$cmsPage->setUpdateTime(Varien_Date::now())->setStores(array($cmspages['store_ids']))->setIsActive($cmspages['is_active'])->setTitle($cmspages['title'])->setContent($cmspages['content'])->setRootTemplate($cmspages['root_template'])->setMetaKeywords($cmspages['meta_keywords'])->setMetaDescription($cmspages['meta_description'])->setContentHeading($cmspages['content_heading'])->setSortOrder($cmspages['sort_order'])->setLayoutUpdateXml($cmspages['layout_update_xml'])->setCustomTheme($cmspages['custom_theme'])->setCustomRootTemplate($cmspages['custom_root_template'])->setCustomLayoutUpdateXml($cmspages['custom_layout_update_xml'])->setCustomThemeFrom($cmspages['custom_theme_from'])->setCustomThemeTo($cmspages['custom_theme_to'])->save();
}
} else {
$this->_critical('Empty data found');
}
} catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
$this->_critical(sprintf('Invalid attribute "%s": %s', $e->getAttributeCode(), $e->getMessage()), Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
} catch (Mage_Core_Exception $e) {
$this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
} catch (Exception $e) {
$this->_critical(self::RESOURCE_UNKNOWN_ERROR);
}
}
开发者ID:brentwpeterson,项目名称:magento-cms-update-api,代码行数:27,代码来源:V1.php
示例3: saveAction
public function saveAction()
{
$installment = Mage::getModel('installment/master');
$id = $this->getRequest()->getParam('id');
if (!is_null($id)) {
$installment->load($id);
}
try {
$authPaid = $installment->getInstallmentMasterInstallmentAuthorized() || $installment->getInstallmentMasterInstallmentPaid();
if ($authPaid && $this->getRequest()->getParam('suspend_installment')) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('installment')->__('The installment has been authorized and/or paid and can not be split.'));
$order = Mage::getModel('sales/order')->loadByIncrementId($installment->getOrderId());
$this->getResponse()->setRedirect($this->getUrl('*/sales_order/view', array('order_id' => $order->getId(), 'active_tab' => 'order_installment_payment')));
}
$reason = $this->getRequest()->getParam('suspend_installment') ? $this->getRequest()->getParam('suspended_reason') : '';
$installment->setInstallmentMasterAmountDue($this->getRequest()->getParam('amount_due'))->setInstallmentMasterAmountDueDate(Varien_Date::formatDate($this->getRequest()->getParam('amount_due_date')))->setInstallmentMasterSuspendInstallment($this->getRequest()->getParam('suspend_installment'))->setInstallmentMasterSuspendedReason($reason)->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('installment')->__('The installment payment has been saved.'));
$id = Mage::getModel('sales/order')->loadByIncrementId($this->getRequest()->getParam('order_id'))->getId();
$this->getResponse()->setRedirect($this->getUrl('*/sales_order/view', array('order_id' => $id, 'active_tab' => 'order_installment_payment')));
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setInstallmentPaymentData($installment->getData());
$this->getResponse()->setRedirect($this->getUrl('*/sales_order_payment/edit', array('id' => $id)));
return;
}
}
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:27,代码来源:PaymentController.php
示例4: filterByActiveState
/**
* Apply filter by card active state (based on last usage date)
*
* @return CLS_Paypal_Model_Resource_Customerstored_Collection
*/
public function filterByActiveState()
{
$now = new Zend_Date(null);
$now->addMonth(0 - CLS_Paypal_Model_Paypal_Config::STORED_CARD_TTL_MONTHS);
$this->getSelect()->where('date >= ?', Varien_Date::formatDate($now, false));
return $this;
}
开发者ID:xiaoguizhidao,项目名称:bb,代码行数:12,代码来源:Collection.php
示例5: startAction
/**
* Start edit order initialization
*/
public function startAction()
{
$this->_getSession()->clear();
$orderId = $this->getRequest()->getParam('order_id');
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->getId()) {
$this->_getSession()->setUseOldShippingMethod(true);
$this->_getOrderCreateModel()->initFromOrder($order);
/**
* Lock Order Here
*/
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$condition = array($write->quoteInto('order_id=?', $order->getIncrementId()));
$write->delete('lockorder', $condition);
$sql = "INSERT INTO lockorder values (?,?,?,?,?)";
//insert query
$write->query($sql, array('', $order->getIncrementId(), '1', Varien_Date::now(), ''));
//write to database
/**
* End of Lock Order Here
*/
$this->_redirect('*/*');
} else {
$this->_redirect('*/sales_order/');
}
}
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:29,代码来源:EditController.php
示例6: _beforeSave
/**
* Perform actions before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
* @throws Mage_Core_Exception
*/
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
if ($date = $object->getDateFrom()) {
$object->setDateFrom($this->formatDate($date));
} else {
$object->setDateFrom(null);
}
if ($date = $object->getDateTo()) {
$object->setDateTo($this->formatDate($date));
} else {
$object->setDateTo(null);
}
if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && Varien_Date::toTimestamp($object->getDateFrom()) > Varien_Date::toTimestamp($object->getDateTo())) {
Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Start date cannot be greater than end date.'));
}
$check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
if ($check) {
Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('Your design change for the specified store intersects with another one, please specify another date range.'));
}
if ($object->getDateFrom() === null) {
$object->setDateFrom(new Zend_Db_Expr('null'));
}
if ($object->getDateTo() === null) {
$object->setDateTo(new Zend_Db_Expr('null'));
}
parent::_beforeSave($object);
}
开发者ID:relue,项目名称:magento2,代码行数:34,代码来源:Design.php
示例7: _toHtml
protected function _toHtml()
{
$displayFormat = Varien_Date::convertZendToStrFtime($this->getFormat(), true, (bool) $this->getTime());
$html = '<input type="text" name="' . $this->getName() . '" id="' . $this->getId() . '" ';
$html .= 'value="' . $this->escapeHtml($this->getValue()) . '" class="' . $this->getClass() . '" ' . $this->getExtraParams() . '/> ';
$html .= '<img src="' . $this->getImage() . '" alt="' . $this->helper('core')->__('Select Date') . '" class="v-middle" ';
$html .= 'title="' . $this->helper('core')->__('Select Date') . '" id="' . $this->getId() . '_trig" />';
$html .= '<script type="text/javascript">
//<![CDATA[
var calendarSetupObject = {
inputField : "' . $this->getId() . '",
ifFormat : "' . $displayFormat . '",
showsTime : "' . ($this->getTime() ? 'true' : 'false') . '",
button : "' . $this->getId() . '_trig",
align : "Bl",
singleClick : true
}';
$calendarYearsRange = $this->getYearsRange();
if ($calendarYearsRange) {
$html .= '
calendarSetupObject.range = ' . $calendarYearsRange . '
';
}
$html .= '
Calendar.setup(calendarSetupObject);
//]]>
</script>';
return $html;
}
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:29,代码来源:Date.php
示例8: catalogProductImportFinishBefore
public function catalogProductImportFinishBefore($observer)
{
$productIds = array();
$adapter = $observer->getEvent()->getAdapter();
$resource = Mage::getResourceModel('bubble_stockmovements/stock_movement');
if ($adapter instanceof Mage_Catalog_Model_Convert_Adapter_Product) {
$productIds = $adapter->getAffectedEntityIds();
} else {
Mage_ImportExport_Model_Import::getDataSourceModel()->getIterator()->rewind();
$skus = array();
while ($bunch = $adapter->getNextBunch()) {
foreach ($bunch as $rowData) {
if (null !== $rowData['sku']) {
$skus[] = $rowData['sku'];
}
}
}
if (!empty($skus)) {
$productIds = $resource->getProductsIdBySku($skus);
}
}
if (!empty($productIds)) {
$stock = Mage::getSingleton('cataloginventory/stock');
$stocks = Mage::getResourceModel('cataloginventory/stock')->getProductsStock($stock, $productIds);
$stocksMovements = array();
$datetime = Varien_Date::formatDate(time());
foreach ($stocks as $stockData) {
$stocksMovements[] = array('item_id' => $stockData['item_id'], 'user' => $this->_getUsername(), 'user_id' => $this->_getUserId(), 'qty' => $stockData['qty'], 'is_in_stock' => (int) $stockData['is_in_stock'], 'message' => 'Product import', 'created_at' => $datetime);
}
if (!empty($stocksMovements)) {
$resource->insertStocksMovements($stocksMovements);
}
}
}
开发者ID:jadhub,项目名称:magento-stock-movements,代码行数:34,代码来源:Observer.php
示例9: setSelectPeriod
/**
* Filters the summaries by some period
*
* @param string $periodType
* @param string|int|null $customStart
* @param string|int|null $customEnd
* @return Mage_Reports_Model_Resource_Entity_Summary_Collection_Abstract
*/
public function setSelectPeriod($periodType, $customStart = null, $customEnd = null)
{
switch ($periodType) {
case "24h":
$customStart = Varien_Date::toTimestamp(true) - 86400;
$customEnd = Varien_Date::toTimestamp(true);
break;
case "7d":
$customStart = Varien_Date::toTimestamp(true) - 604800;
$customEnd = Varien_Date::toTimestamp(true);
break;
case "30d":
$customStart = Varien_Date::toTimestamp(true) - 2592000;
$customEnd = Varien_Date::toTimestamp(true);
break;
case "1y":
$customStart = Varien_Date::toTimestamp(true) - 31536000;
$customEnd = Varien_Date::toTimestamp(true);
break;
default:
if (is_string($customStart)) {
$customStart = strtotime($customStart);
}
if (is_string($customEnd)) {
$customEnd = strtotime($customEnd);
}
break;
}
return $this;
}
开发者ID:par-orillonsoft,项目名称:Magento,代码行数:38,代码来源:Abstract.php
示例10: getElementHtml
public function getElementHtml()
{
$this->addClass('input-text');
$html = sprintf('<input name="%s" id="%s" value="%s" %s style="width:110px !important; float:left;" />' . ' <img src="%s" alt="" class="v-middle" id="%s_trig" title="%s" style="position: relative;top: 8px;left:3px%s" />' . '<div style="clear: both;"></div>', $this->getName(), $this->getHtmlId(), $this->_escape($this->getValue()), $this->serialize($this->getHtmlAttributes()), $this->getImage(), $this->getHtmlId(), 'Select Date', $this->getDisabled() ? 'display:none;' : '');
$outputFormat = $this->getFormat();
if (empty($outputFormat)) {
throw new Exception('Output format is not specified. Please, specify "format" key in constructor, or set it using setFormat().');
}
$displayFormat = Varien_Date::convertZendToStrFtime($outputFormat, true, (bool) $this->getTime());
$html .= sprintf('
<script type="text/javascript">
//<![CDATA[
Calendar.setup({
inputField: "%s",
ifFormat: "%s",
showsTime: %s,
button: "%s_trig",
align: "Bl",
singleClick : true
});
//]]>
</script>', $this->getHtmlId(), $displayFormat, $this->getTime() ? 'true' : 'false', $this->getHtmlId());
$html .= $this->getAfterElementHtml();
return $html;
}
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:25,代码来源:Date.php
示例11: render
public function render(Varien_Object $row)
{
$html = parent::render($row);
$hlp = Mage::helper('udropship');
if ($this->getColumn()->getEditable()) {
$calGridUrl = Mage::getDesign()->getSkinUrl('images/grid-cal.gif');
$date = $row->getData($this->getColumn()->getIndex());
if ($date) {
$date = $hlp->dateInternalToLocale($date);
}
$_dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$_calDateFormat = Varien_Date::convertZendToStrFtime($_dateFormat, true, false);
$htmlId = '_' . md5(uniqid(microtime(), true));
$html .= <<<EOT
<input id="{$htmlId}" type="text" class="input-text" name="{$this->getColumn()->getId()}" value="{$date}" style="width:110px !important;" />
<!--img src="{$calGridUrl}" alt="" class="v-middle"title="" style="" /-->
</nobr>
<script type="text/javascript">
//<![CDATA[
Calendar.setup({
inputField: "{$htmlId}",
ifFormat: "{$_calDateFormat}",
showsTime: false,
button: "{$htmlId}_trig",
align: "Bl",
singleClick : true
});
//]]>
</script>
EOT;
}
return $html;
}
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:33,代码来源:Date.php
示例12: catalogProductImportFinishBefore
public function catalogProductImportFinishBefore($observer)
{
$adapter = $observer->getEvent()->getAdapter();
Mage_ImportExport_Model_Import::getDataSourceModel()->getIterator()->rewind();
$model = Mage::getModel('catalog/product');
$skus = array();
while ($bunch = $adapter->getNextBunch()) {
foreach ($bunch as $rowData) {
if (null !== $rowData['sku']) {
$skus[] = $rowData['sku'];
}
}
}
if (!empty($skus)) {
$resource = Mage::getResourceModel('jr_stockhistory/stock_history');
$productIds = $resource->getProductsIdBySku($skus);
if (!empty($productIds)) {
$stock = Mage::getSingleton('cataloginventory/stock');
$stocks = Mage::getResourceModel('cataloginventory/stock')->getProductsStock($stock, $productIds);
$stocksHistory = array();
$datetime = Varien_Date::formatDate(time());
foreach ($stocks as $stockData) {
$stocksHistory[] = array('item_id' => $stockData['item_id'], 'user' => $this->_getUsername(), 'user_id' => $this->_getUserId(), 'qty' => $stockData['qty'], 'is_in_stock' => (int) $stockData['is_in_stock'], 'message' => 'Product import', 'created_at' => $datetime);
}
if (!empty($stocksHistory)) {
$resource->insertStocksHistory($stocksHistory);
}
}
}
}
开发者ID:r-martins,项目名称:magento-stock-history,代码行数:30,代码来源:Observer.php
示例13: send
/**
* Send all messages in a queue
*
* @return Mage_Core_Model_Email_Queue
*/
public function send()
{
/** @var $collection Mage_Core_Model_Resource_Email_Queue_Collection */
$collection = Mage::getModel('core/email_queue')->getCollection()->addOnlyForSendingFilter()->setPageSize(self::MESSAGES_LIMIT_PER_CRON_RUN)->setCurPage(1)->load();
ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
/** @var $message Mage_Core_Model_Email_Queue */
foreach ($collection as $message) {
if ($message->getId()) {
$parameters = new Varien_Object($message->getMessageParameters());
if ($parameters->getReturnPathEmail() !== null) {
$mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $parameters->getReturnPathEmail());
Zend_Mail::setDefaultTransport($mailTransport);
}
$mailer = new Zend_Mail('utf-8');
foreach ($message->getRecipients() as $recipient) {
list($email, $name, $type) = $recipient;
switch ($type) {
case self::EMAIL_TYPE_BCC:
$mailer->addBcc($email, '=?utf-8?B?' . base64_encode($name) . '?=');
break;
case self::EMAIL_TYPE_TO:
case self::EMAIL_TYPE_CC:
default:
$mailer->addTo($email, '=?utf-8?B?' . base64_encode($name) . '?=');
break;
}
}
if ($parameters->getIsPlain()) {
$mailer->setBodyText($message->getMessageBody());
} else {
$mailer->setBodyHTML($message->getMessageBody());
}
$mailer->setSubject('=?utf-8?B?' . base64_encode($parameters->getSubject()) . '?=');
$mailer->setFrom($parameters->getFromEmail(), $parameters->getFromName());
if ($parameters->getReplyTo() !== null) {
$mailer->setReplyTo($parameters->getReplyTo());
}
if ($parameters->getReturnTo() !== null) {
$mailer->setReturnPath($parameters->getReturnTo());
}
try {
//$mailer->send();
$mailer->send(Mage::helper('smtp')->getTransport());
unset($mailer);
$message->setProcessedAt(Varien_Date::formatDate(true));
$message->save();
} catch (Exception $e) {
unset($mailer);
$oldDevMode = Mage::getIsDeveloperMode();
Mage::setIsDeveloperMode(true);
Mage::logException($e);
Mage::setIsDeveloperMode($oldDevMode);
return false;
}
}
}
return $this;
}
开发者ID:TomOhme,项目名称:IP1-Webshop,代码行数:64,代码来源:Queue.php
示例14: beforeSave
/**
* Set created date
*
* @param Mage_Core_Model_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
if ($object->isObjectNew() && is_null($object->getData($attributeCode))) {
$object->setData($attributeCode, Varien_Date::now());
}
return $this;
}
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:14,代码来源:Created.php
示例15: _beforeSave
/**
* If object is new adds creation date
*
* @return NoPro_Bluemoon_Model_Bluemoon
*/
protected function _beforeSave()
{
parent::_beforeSave();
if ($this->isObjectNew()) {
$this->setData('created_at', Varien_Date::now());
}
return $this;
}
开发者ID:nopro,项目名称:bluemoon,代码行数:13,代码来源:Bluemoon.php
示例16: setDate
protected function setDate()
{
$currentTime = Varien_Date::now();
if ((!$this->getId() || $this->isObjectNew()) && !$this->getCreatedAt()) {
$this->setCreatedAt($currentTime);
}
return $this;
}
开发者ID:Rodrifer,项目名称:candyclub,代码行数:8,代码来源:Log.php
示例17: getLoginAtTimestamp
/**
* Return last login at in Unix time format
*
* @return int
*/
public function getLoginAtTimestamp()
{
$loginAt = $this->getLoginAt();
if ($loginAt) {
return Varien_Date::toTimestamp($loginAt);
}
return null;
}
开发者ID:relue,项目名称:magento2,代码行数:13,代码来源:Customer.php
示例18: cleanLogs
/**
* Clean the log table
*
* @param int $keepDays Days to keep
* @return int The number of deleted rows
*/
public function cleanLogs($keepDays)
{
if (!$keepDays) {
return 0;
}
$time = Mage::getModel('core/date')->gmtTimestamp() - 60 * 60 * 24 * $keepDays;
$delete = Varien_Date::formatDate($time, false);
return $this->_getWriteAdapter()->delete($this->getMainTable(), $this->_getWriteAdapter()->quoteInto('timestamp < ?', $delete));
}
开发者ID:kirchbergerknorr,项目名称:firegento-logger,代码行数:15,代码来源:Entry.php
示例19: now
/**
* Return the current date in internal format.
*
* @param bool $withoutTime day only flag
*
* @return string
*/
public function now($withoutTime = false)
{
if (method_exists("Varien_Date", "now")) {
return Varien_Date::now($withoutTime);
} else {
$format = $withoutTime ? "Y-m-d" : "Y-m-d H:i:s";
return date($format);
}
}
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:16,代码来源:Compat.php
示例20: deleteOldEntries
/**
* Delete old entries
*
* @param int $minutes
* @return int
*/
public function deleteOldEntries($minutes)
{
if ($minutes > 0) {
$adapter = $this->_getWriteAdapter();
return $adapter->delete($this->getMainTable(), $adapter->quoteInto('type = "' . Mage_Oauth_Model_Token::TYPE_REQUEST . '" AND created_at <= ?', Varien_Date::formatDate(time() - $minutes * 60)));
} else {
return 0;
}
}
开发者ID:nemphys,项目名称:magento2,代码行数:15,代码来源:Token.php
注:本文中的Varien_Date类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论