本文整理汇总了PHP中Axis::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Axis::model方法的具体用法?PHP Axis::model怎么用?PHP Axis::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axis
的用法示例。
在下文中一共展示了Axis::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeRender
protected function _beforeRender()
{
$visitor = Axis::model('log/visitor')->getVisitor();
// select all viewed products by current visitor
$selectInner = Axis::model('log/event')->select(array('id', 'object_id'))->order('le.id DESC');
$customerId = $visitor->customer_id;
if ($customerId && $customerId === Axis::getCustomerId()) {
$selectInner->join('log_visitor', 'le.visitor_id = lv.id')->where('lv.customer_id = ?', $customerId);
} else {
$selectInner->where('visitor_id = ?', $visitor->id);
}
// filter unique product_ids from correctly ordered query
// using adapter for specific from statement
// this subquery is used to get the correct order for products
// bigfix for not displayed product if the user viewed it some time ago and now opened it again
// with single query this product will not outputted first in a row
$adapter = Axis::model('log/event')->getAdapter();
$select = $adapter->select()->from(array('le' => $selectInner), 'object_id')->group('le.object_id')->order('le.id DESC')->limit($this->getProductsCount());
$productIds = $adapter->fetchCol($select);
if (empty($productIds)) {
return false;
}
$products = Axis::model('catalog/product')->select('*')->addFilterByAvailability()->addCommonFields()->addFinalPrice()->joinCategory()->where('cc.site_id = ?', Axis::getSiteId())->where('cp.id IN (?)', $productIds)->fetchProducts($productIds);
if (empty($products)) {
return false;
}
$this->products = $products;
return $this->hasProducts();
}
示例2: up
public function up()
{
/**
* we didn't have the foreign keys between account_customer_address and default addresses,
* so before applying the upgrade, have to cleanup possible issues
*/
$customerRowset = Axis::model('account/customer')->select()->where('default_billing_address_id IS NOT NULL')->orWhere('default_shipping_address_id IS NOT NULL')->fetchRowset();
$addressIds = Axis::model('account/customer_address')->select(array('id', 'customer_id'))->fetchPairs();
foreach ($customerRowset as $customerRow) {
$save = false;
if (!isset($addressIds[$customerRow->default_billing_address_id])) {
$customerRow->default_billing_address_id = new Zend_Db_Expr('NULL');
$save = true;
}
if (!isset($addressIds[$customerRow->default_shipping_address_id])) {
$customerRow->default_shipping_address_id = new Zend_Db_Expr('NULL');
$save = true;
}
if ($save) {
$customerRow->save();
}
}
// add foreign keys
$installer = Axis::single('install/installer');
$installer->run("\n\n ALTER TABLE `{$installer->getTable('account_customer')}`\n ADD CONSTRAINT `FK_ACCOUNT_CUSTOMER_SHIPPING_ADDRESS` FOREIGN KEY `FK_ACCOUNT_CUSTOMER_SHIPPING_ADDRESS` (`default_shipping_address_id`)\n REFERENCES `{$installer->getTable('account_customer_address')}` (`id`)\n ON DELETE CASCADE\n ON UPDATE CASCADE,\n ADD CONSTRAINT `FK_ACCOUNT_CUSTOMER_BILLING_ADDRESS` FOREIGN KEY `FK_ACCOUNT_CUSTOMER_BILLING_ADDRESS` (`default_billing_address_id`)\n REFERENCES `{$installer->getTable('account_customer_address')}` (`id`)\n ON DELETE CASCADE\n ON UPDATE CASCADE;\n\n ");
}
示例3: removeAction
public function removeAction()
{
$id = $this->_getParam('id');
Axis::model('admin/acl_role')->delete($this->db->quoteInto('id = ?', $id));
Axis::message()->addSuccess(Axis::translate('admin')->__('Role was deleted successfully'));
return $this->_helper->json->sendSuccess();
}
示例4: addAction
/**
* Customer add new tag on product
* @return void
*/
public function addAction()
{
$tags = array_filter(explode(',', $this->_getParam('tags')));
$productId = $this->_getParam('productId');
$modelCustomer = Axis::model('tag/customer');
$modelProduct = Axis::model('tag/product');
$defaultStatus = $modelCustomer->getDefaultStatus();
$customerId = Axis::getCustomerId();
$siteId = Axis::getSiteId();
$_row = array('customer_id' => $customerId, 'site_id' => $siteId, 'status' => $modelCustomer->getDefaultStatus());
foreach ($tags as $tag) {
$row = $modelCustomer->select()->where('name = ?', $tag)->where('customer_id = ?', $customerId)->where('site_id = ?', $siteId)->fetchRow();
if (!$row) {
$_row['name'] = $tag;
$row = $modelCustomer->createRow($_row);
$row->save();
Axis::message()->addSuccess(Axis::translate('tag')->__("Tag '%s' was successfully added to product", $tag));
} else {
Axis::message()->addNotice(Axis::translate('tag')->__("Your tag '%s' is already added to this product", $tag));
}
// add to product relation
$isExist = (bool) $modelProduct->select('id')->where('customer_tag_id = ?', $row->id)->where('product_id = ?', $productId)->fetchOne();
if (!$isExist) {
$modelProduct->createRow(array('customer_tag_id' => $row->id, 'product_id' => $productId))->save();
}
Axis::dispatch('tag_product_add_success', array('tag' => $tag, 'product_id' => $productId));
}
$this->_redirect($this->getRequest()->getServer('HTTP_REFERER'));
}
示例5: _isEnabled
protected function _isEnabled()
{
if (null === $this->_enabled) {
$this->_enabled = parent::_isEnabled() && Axis::model('PaymentPaypal/Express')->isEnabled();
}
return $this->_enabled;
}
示例6: getAllowedTypes
public function getAllowedTypes($request)
{
switch ($this->_config->type) {
case Axis_ShippingTable_Model_Option_Standard_Service::PER_WEIGHT:
$value = $request['weight'];
break;
case Axis_ShippingTable_Model_Option_Standard_Service::PER_ITEM:
$value = $request['qty'];
break;
case Axis_ShippingTable_Model_Option_Standard_Service::PER_PRICE:
default:
$value = $request['price'];
break;
}
$select = Axis::model('shippingTable/rate')->select();
$select->where('value <= ? ', $value)->where('site_id = ? OR site_id = 0', Axis::getSiteId())->where('country_id = ? OR country_id = 0', $request['country']['id'])->where('zip = ? OR zip = "*"', $request['postcode'])->order('site_id DESC')->order('country_id ASC')->order('zone_id ASC')->order('zip ASC')->order('value DESC')->limit(1);
if (isset($request['zone']['id'])) {
$select->where('zone_id = ? OR zone_id = 0', $request['zone']['id']);
} else {
$select->where('zone_id = 0');
}
$row = $select->fetchRow();
if ($row) {
$handling = is_numeric($this->_config->handling) ? $this->_config->handling : 0;
$this->_types = array(array('id' => $this->_code, 'title' => $this->getTitle(), 'price' => $row['price'] + $handling));
}
return $this->_types;
}
示例7: save
/**
* Update or delete manufacturer row
* Checks is recieved url has duplicate before save.
* If it has - throws an exception
*
* @param array $data
* <pre>
* Array(
* id, name, key_word,
* description => array(
* langId => array()
* )
* )
* </pre>
* @return int Manufacturer id
* @throws Axis_Exception
*/
public function save(array $data)
{
$row = $this->getRow($data);
//$row->setUrl();
//before save
$url = trim($data['key_word']);
if (empty($url)) {
$url = $data['name'];
}
// $url = preg_replace('/[^a-zA-Z0-9]/', '-', $url);
if (Axis::single('catalog/hurl')->hasDuplicate($url, array_keys(Axis::model('core/option_site')->toArray()), (int) $row->id)) {
throw new Axis_Exception(Axis::translate('core')->__('Column %s should be unique', 'url'));
}
$row->image = empty($row->image) ? '' : '/' . trim($row->image, '/');
//end before save
$row->save();
//after save
//add relation site
$model = Axis::model('catalog/hurl');
foreach (Axis::model('core/option_site') as $siteId => $siteName) {
$model->save(array('site_id' => $siteId, 'key_id' => $row->id, 'key_type' => 'm', 'key_word' => $url));
}
//end after save
return $row;
}
示例8: getValuesArrayByLanguage
/**
*
* @param int $languageId
* @return array
*/
public function getValuesArrayByLanguage($languageId)
{
if (!$this->valueset_id) {
return array();
}
return Axis::model('catalog/product_option_value')->select('*')->join('catalog_product_option_value_text', 'cpov.id = cpovt.option_value_id', 'name')->where('cpov.valueset_id = ?', $this->valueset_id)->where('cpovt.language_id = ?', $languageId)->fetchAll();
}
示例9: registerAction
public function registerAction()
{
$this->setTitle(Axis::translate('account')->__('Forgot password'));
$username = $this->_getParam('username', null);
if (empty($username)) {
$this->render();
return;
}
$customerId = Axis::single('account/customer')->getIdByEmail($username);
if ($customerId && ($customer = Axis::single('account/customer')->find($customerId)->current()) && Axis::getSiteId() === $customer->site_id) {
$modelForgotPassword = Axis::model('account/customer_forgotPassword');
$hash = $modelForgotPassword->generatePassword();
$link = $this->view->href('account/forgot', true) . '?hash=' . $hash;
try {
$mail = new Axis_Mail();
$configResult = $mail->setConfig(array('event' => 'forgot_password', 'subject' => Axis::translate('account')->__('Forgotten Password'), 'data' => array('link' => $link, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname), 'to' => $username));
if ($configResult) {
$mail->send();
$modelForgotPassword->save(array('hash' => $hash, 'customer_id' => $customerId));
Axis::message()->addSuccess(Axis::translate('core')->__('Message was sended to you. Check your mailbox'));
}
} catch (Zend_Mail_Exception $e) {
Axis::message()->addError(Axis::translate('core')->__('Mail sending was failed.'));
}
} else {
Axis::message()->addError(Axis::translate('account')->__("'%s' was not found in database", $username));
}
$this->render();
}
示例10: batchSaveAction
public function batchSaveAction()
{
$dataset = Zend_Json::decode($this->_getParam('data'));
if (!sizeof($dataset)) {
Axis::message()->addError(Axis::translate('core')->__('No data to save'));
return $this->_helper->json->sendFailure();
}
$model = Axis::model('admin/user');
foreach ($dataset as $data) {
if (!empty($data['password'])) {
$data['password'] = md5($data['password']);
} else {
unset($data['password']);
}
$row = $model->getRow($data);
$row->is_active = false;
$row->is_active = !empty($data['is_active']);
$row->modified = Axis_Date::now()->toSQLString();
if (empty($row->created)) {
$row->created = $row->modified;
}
$row->save();
}
Axis::message()->addSuccess(Axis::translate('admin')->__('User was saved successfully'));
return $this->_helper->json->sendSuccess();
}
示例11: viewPageAction
public function viewPageAction()
{
$link = $this->_getParam('page');
$pageId = Axis::single('cms/page')->getPageIdByLink($link);
$rowPage = Axis::single('cms/page')->find($pageId)->current();
if (!$rowPage || !$rowPage->is_active) {
return $this->_forward('not-found', 'Error', 'Axis_Core');
}
$rowContent = $rowPage->getContent();
$categories = Axis::single('cms/category')->cache()->getParentCategory($pageId, true);
foreach ($categories as $_category) {
$label = empty($_category['title']) ? $_category['link'] : $_category['title'];
$this->_helper->breadcrumbs(array('label' => $label, 'params' => array('cat' => $_category['link']), 'route' => 'cms_category'));
}
$page = array('id' => $rowPage->id, 'content' => $rowContent->content, 'is_commented' => $rowPage->comment);
if ($rowPage->comment) {
// get all comments
$comments = $rowPage->cache()->getComments();
foreach ($comments as $comment) {
$page['comment'][] = $comment;
}
// create comment form
$this->view->formComment = Axis::model('cms/form_comment', array('pageId' => $rowPage->id));
}
$this->view->page = $page;
$this->setTitle($rowContent->title);
$metaTitle = empty($rowContent->meta_title) ? $rowContent->title : $rowContent->meta_title;
$this->view->meta()->setTitle($metaTitle, 'cms_page', $pageId)->setDescription($rowContent->meta_description)->setKeywords($rowContent->meta_keyword);
$this->_helper->layout->setLayout($rowPage->layout);
$this->render();
}
示例12: up
public function up()
{
$installer = $this->getInstaller();
$installer->run("\n\n -- DROP TABLE IF EXISTS `{$installer->getTable('community_media')}`;\n CREATE TABLE IF NOT EXISTS `{$installer->getTable('community_media')}` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `path` varchar(255) NOT NULL,\n `product_id` int(10) unsigned default NULL,\n `customer_id` int(10) unsigned default NULL,\n `status` enum('pending','approved','disapproved') NOT NULL,\n `size` double NOT NULL,\n `date_uploaded` datetime NOT NULL,\n `author` varchar(128) NOT NULL,\n `title` varchar(128) NOT NULL,\n `description` varchar(255) NOT NULL,\n `media_type` enum('video','image') NOT NULL,\n `width` smallint(5) unsigned NOT NULL default '0',\n `height` smallint(5) unsigned NOT NULL default '0',\n PRIMARY KEY (`id`),\n KEY `FK_community_media_product` (`product_id`),\n KEY `FK_community_media_customer` (`customer_id`),\n CONSTRAINT `FK_community_media_customer` FOREIGN KEY (`customer_id`) REFERENCES `{$installer->getTable('account_customer')}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,\n CONSTRAINT `FK_community_media_product` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product')}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n -- DROP TABLE IF EXISTS `{$installer->getTable('community_review')}`;\n CREATE TABLE IF NOT EXISTS `{$installer->getTable('community_review')}` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `product_id` int(10) unsigned NOT NULL,\n `customer_id` int(10) unsigned default NULL,\n `status` enum('pending','approved','disapproved') NOT NULL,\n `summary` text NOT NULL,\n `author` varchar(128) NOT NULL,\n `title` varchar(128) NOT NULL,\n `date_created` datetime NOT NULL,\n `pros` varchar(255) NOT NULL,\n `cons` varchar(255) NOT NULL,\n PRIMARY KEY (`id`),\n KEY `FK_community_review_customer` (`customer_id`),\n CONSTRAINT `FK_community_review_customer` FOREIGN KEY (`customer_id`) REFERENCES `{$installer->getTable('account_customer')}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,\n CONSTRAINT `FK_community_review_product` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n\n -- DROP TABLE IF EXISTS `{$installer->getTable('community_review_mark')}`;\n CREATE TABLE IF NOT EXISTS `{$installer->getTable('community_review_mark')}` (\n `review_id` int(10) unsigned NOT NULL default '0',\n `rating_id` int(10) unsigned NOT NULL,\n `mark` float default NULL,\n PRIMARY KEY (`review_id`,`rating_id`),\n KEY `FK_community_review_mark_rating` (`rating_id`),\n CONSTRAINT `FK_community_review_mark_review` FOREIGN KEY (`review_id`) REFERENCES `{$installer->getTable('community_review')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `FK_community_review_mark_rating` FOREIGN KEY (`rating_id`) REFERENCES `{$installer->getTable('community_review_rating')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n\n -- DROP TABLE IF EXISTS `{$installer->getTable('community_review_rating')}`;\n CREATE TABLE IF NOT EXISTS `{$installer->getTable('community_review_rating')}` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `name` varchar(64) NOT NULL,\n `status` enum('enabled','disabled') NOT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;\n\n INSERT INTO `{$installer->getTable('community_review_rating')}` (`id`, `status`, `name`) VALUES\n (1, 'enabled', 'price'),\n (2, 'enabled', 'quality'),\n (3, 'enabled', 'value');\n\n -- DROP TABLE IF EXISTS `{$installer->getTable('community_review_rating_title')}`;\n CREATE TABLE IF NOT EXISTS `{$installer->getTable('community_review_rating_title')}` (\n `rating_id` int(10) unsigned NOT NULL,\n `language_id` smallint(5) unsigned NOT NULL,\n `title` varchar(128) NOT NULL,\n PRIMARY KEY USING BTREE (`rating_id`,`language_id`),\n KEY `FK_community_review_rating_title_language_id` (`language_id`),\n CONSTRAINT `FK_community_review_rating_title_language_id` FOREIGN KEY (`language_id`) REFERENCES `{$installer->getTable('locale_language')}` (`id`) ON DELETE CASCADE,\n CONSTRAINT `FK_community_review_rating_title_rating_id` FOREIGN KEY (`rating_id`) REFERENCES `{$installer->getTable('community_review_rating')}` (`id`) ON DELETE CASCADE\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n ");
$titles = array('Price', 'Quality', 'Value');
$languages = Axis::model('locale/option_language');
$mRatingTitle = Axis::model('community/review_rating_title');
foreach (Axis::model('community/review_rating')->fetchAll() as $rating) {
foreach ($languages as $languageId => $languageName) {
$mRatingTitle->createRow(array('rating_id' => $rating->id, 'language_id' => $languageId, 'title' => $titles[$rating->id - 1]))->save();
}
}
$this->getConfigBuilder()->section('community', 'Community')->setTranslation('Axis_Community')->section('review', 'Reviews')->option('enabled', 'Enabled', true)->setType('radio')->setModel('core/option_boolean')->option('rating_enabled', 'Enable ratings', true)->setType('radio')->setDescription('Enable rating system in reviews')->setModel('core/option_boolean')->option('rating_title', 'Show rating title', true)->setType('radio')->setDescription('Show rating titles')->setModel('core/option_boolean')->option('merge_average', 'Merge average ratings', true)->setType('radio')->setDescription('Show average rating as one')->setModel('core/option_boolean')->option('customer_status', 'Default customer review status')->setValue(Axis_Community_Model_Option_Review_Status::PENDING)->setType('select')->setDescription('Default review status written by registered customer')->setModel('community/option_review_status')->option('guest_status', 'Default guest review status')->setValue(Axis_Community_Model_Option_Review_Status::PENDING)->setType('select')->setDescription('Default review status written by guest')->setModel('community/option_review_status')->option('guest_permission', 'Allow guest to write a reviews', true)->setType('radio')->setModel('core/option_boolean')->option('perPage', 'Reviews showed per page', '10,25,50,all')->option('perPageDefault', 'Default reviews count per page', '10')->section('/review')->section('/');
Axis::single('account/customer_field')->add(array('nickname' => 'Nickname'), array('community' => 'Community'), array('validator' => 'Alnum', 'axis_validator' => 'Axis_Community_Validate_Nickname'));
Axis::single('core/page')->add('community/*/*')->add('community/review/*')->add('community/review/index')->add('community/review/detail')->add('community/review/product')->add('community/review/customer');
/*->add('community/image/*')
->add('community/image/index')
->add('community/image/detail')
->add('community/image/product')
->add('community/image/customer')
->add('community/video/*')
->add('community/video/index')
->add('community/video/detail')
->add('community/video/product')
->add('community/video/customer');*/
}
示例13: up
public function up()
{
$installer = $this->getInstaller();
$installer->run("\n\n ALTER TABLE `{$installer->getTable('core_template_box_page')}`\n MODIFY COLUMN `sort_order` TINYINT(3) DEFAULT NULL;\n\n ");
$rowset = Axis::model('core/template_box')->fetchAll();
foreach ($rowset as $row) {
if (empty($row->config)) {
$row->config = '{}';
$row->save();
continue;
}
try {
if (is_array(Zend_Json::decode($row->config))) {
continue;
}
} catch (Exception $e) {
// non-json content
}
$config = array();
foreach (explode(',', $row->config) as $_param) {
list($key, $value) = explode(':', $_param);
if ('disable_wrapper' === $key) {
$value = (int) $value;
}
$config[$key] = $value;
}
$row->config = Zend_Json::encode($config);
$row->save();
}
}
示例14: _loadCollection
/**
*
* @return array
*/
protected function _loadCollection()
{
if (empty($this->_collection)) {
$themes = Axis::model('core/option_theme');
$layouts = array();
$designPath = Axis::config('system/path') . '/app/design/front';
foreach ($themes as $theme) {
$path = $designPath . '/' . $theme . '/layouts';
if (!file_exists($path)) {
continue;
}
$dir = opendir($path);
while ($file = readdir($dir)) {
if (is_dir($path . '/' . $file) || substr($file, 0, 7) != 'layout_') {
continue;
}
$layout = substr($file, 0, -6);
if (isset($layouts[$layout])) {
$layouts[$layout]['themes'][] = $theme;
continue;
}
$layouts[$layout] = array('name' => $layout, 'themes' => array($theme));
}
}
$collection = array();
foreach ($layouts as $key => $layout) {
$collection[$key] = $layout['name'] . ' (' . implode(', ', $layout['themes']) . ')';
}
$this->_collection = $collection;
}
return $this->_collection;
}
示例15: removeAction
public function removeAction()
{
$data = Zend_Json::decode($this->_getParam('data'));
Axis::model('account/customer_valueSet')->delete($this->db->quoteInto('id IN (?)', $data));
Axis::message()->addSuccess(Axis::translate('admin')->__('Group was deleted successfully'));
return $this->_helper->json->sendSuccess();
}