当前位置: 首页>>代码示例>>PHP>>正文


PHP App::Import方法代码示例

本文整理汇总了PHP中App::Import方法的典型用法代码示例。如果您正苦于以下问题:PHP App::Import方法的具体用法?PHP App::Import怎么用?PHP App::Import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::Import方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateCounterCache

 function updateCounterCache($keys = array(), $created = false)
 {
     parent::updateCounterCache($keys);
     if (isset($this->data['Purchase'])) {
         $this->log('Purchase::updateCounterCache');
         $this->log(array_keys($this->data));
         $cat_id = $this->data['Purchase']['category_id'];
         $date = $this->data['Purchase']['date'];
         // UPDATE MONTH TOTALS
         $dts = strtotime($date);
         $month = date('Y-m-01', $dts);
         $dts = strtotime($month);
         $next_month = date('Y-m-01', strtotime('+1 month', $dts));
         $month_sum = $this->find('first', array('fields' => 'SUM(amount) as amount', 'conditions' => array("Purchase.date >= '{$month}'", "Purchase.date < '{$next_month}'", 'Purchase.category_id' => $cat_id)));
         $month_sum = Set::extract($month_sum, 'Purchase.amount');
         App::Import('Model', 'MonthTotal');
         $m = new MonthTotal();
         $data = array('MonthTotal' => array('id' => $month . '-' . $cat_id, 'date' => $month, 'category_id' => $cat_id, 'amount' => $month_sum));
         $m->save($data);
         // UPDATE YEAR TOTALS
         $year = date('Y', strtotime($date)) . '-01-01';
         $dts = strtotime($date);
         $year = date('Y-01-01', $dts);
         $dts = strtotime($year);
         $next_year = date('Y-01-01', strtotime('+1 year', $dts));
         $year_sum = $this->find('first', array('fields' => 'SUM(amount) as amount', 'conditions' => array("Purchase.date >= '{$year}'", "Purchase.date < '{$next_year}'", 'Purchase.category_id' => $cat_id)));
         $year_sum = Set::extract($year_sum, 'Purchase.amount');
         App::Import('Model', 'YearTotal');
         $m = new YearTotal();
         $data = array('YearTotal' => array('id' => $year . '-' . $cat_id, 'date' => $year, 'category_id' => $cat_id, 'amount' => $year_sum));
         $m->save($data);
     }
 }
开发者ID:02468,项目名称:ebocash,代码行数:33,代码来源:purchase.php

示例2: onActivate

 /**
  * Called after activating the hook in ExtensionsHooksController::admin_toggle()
  *
  * @param object $controller Controller
  * @return void
  */
 function onActivate(&$controller)
 {
     // ACL: set ACOs with permissions
     $controller->Croogo->addAco('NodeSchema');
     // the controller
     $controller->Croogo->addAco('NodeSchema/admin_index');
     // admin methods
     $controller->Croogo->addAco('NodeSchema/admin_add');
     $controller->Croogo->addAco('NodeSchema/admin_edit');
     $controller->Croogo->addAco('NodeSchema/admin_delete');
     $controller->Croogo->addAco('NodeSchema/admin_add_schema_field');
     $controller->Croogo->addAco('NodeSchema/admin_import');
     $controller->Croogo->addAco('NodeSchema/admin_export');
     // Install the database tables we need
     App::Import('CakeSchema');
     $CakeSchema = new CakeSchema();
     $db =& ConnectionManager::getDataSource('default');
     // TODO: How do we change this for installs?
     // A list of schema files to import for this plugin to work
     $schema_files = array('node_schema_fields.php', 'node_schemas.php', 'node_schemas_types.php');
     foreach ($schema_files as $schema_file) {
         $class_name = Inflector::camelize(substr($schema_file, 0, -4)) . 'Schema';
         $table_name = substr($schema_file, 0, -4);
         // Only build the tables if they don't already exist
         if (!in_array($table_name, $db->_sources)) {
             include_once APP . 'plugins' . DS . 'node_schema' . DS . 'config' . DS . 'schema' . DS . $schema_file;
             // Can app import also work here?
             $ActivateSchema = new $class_name();
             $created = false;
             if (isset($ActivateSchema->tables[$table_name])) {
                 $db->execute($db->createSchema($ActivateSchema, $table_name));
             }
         }
     }
 }
开发者ID:hgassen,项目名称:node_schema,代码行数:41,代码来源:node_schema_hook.php

示例3: shophead_index

 /**
  * This function use for product category Listing  in admin panel
  */
 function shophead_index()
 {
     $this->layout = 'admin_layout';
     $this->set('title', 'Product Items Management');
     App::Import("Model", "ProductCategory");
     $this->ProductCategory = new ProductCategory();
     $categories_list = $this->ProductCategory->find('list', array('conditions' => array('ProductCategory.is_deleted' => 0), 'fields' => array('ProductCategory.id', 'ProductCategory.name')));
     $this->set('categories_list', $categories_list);
     $Category_join = array('table' => 'product_sub_categories', 'alias' => 'ProductSubCategory', 'type' => 'inner', 'conditions' => array('ProductItem.product_sub_category_id =ProductSubCategory.id'));
     $conditions = array('ProductItem.is_deleted' => 0);
     if (!empty($this->request->data)) {
         if ($this->request->data['ProductItem']['product_sub_category_id'] != "") {
             $conditions['ProductItem.product_sub_category_id'] = $this->request->data['ProductItem']['product_sub_category_id'];
             $this->request->params['named']['ProductItem.product_sub_category_id'] = $this->request->data['ProductItem']['product_sub_category_id'];
         }
         if ($this->request->data['ProductItem']['product_category_id'] != "") {
             $conditions['ProductItem.product_category_id'] = $this->request->data['ProductItem']['product_category_id'];
             $this->request->params['named']['ProductItem.product_category_id'] = $this->request->data['ProductItem']['product_category_id'];
         }
     } else {
         if (isset($this->request->params['named']['ProductItem.product_category_id']) && $this->request->params['named']['ProductItem.product_category_id'] != "") {
             $conditions['ProductItem.product_category_id'] = $this->request->params['named']['ProductItem.product_category_id'];
             $this->request->data['ProductItem']['product_category_id'] = $this->request->params['named']['ProductItem.product_category_id'];
         }
         if (isset($this->request->params['named']['ProductItem.product_sub_category_id']) && $this->request->params['named']['ProductItem.product_sub_category_id'] != "") {
             $conditions['ProductItem.product_sub_category_id'] = $this->request->params['named']['ProductItem.product_sub_category_id'];
             $this->request->data['ProductItem']['product_sub_category_id'] = $this->request->params['named']['ProductItem.product_sub_category_id'];
         }
     }
     $this->paginate = array('recursive' => 0, 'limit' => LIMIT, 'fields' => array('ProductSubCategory.name as catname,ProductItem.id,ProductItem.name,ProductItem.sort_order,ProductItem.created,ProductItem.status,ProductItem.updated,ProductItem.product_sub_category_id'), 'conditions' => $conditions, 'order' => array('ProductItem.sort_order' => 'Asc'), 'joins' => array($Category_join));
     $result = $this->paginate('ProductItem');
     //pr($result);
     $this->set('result', $result);
 }
开发者ID:89itworld,项目名称:pricecomparison,代码行数:37,代码来源:ProductItemsController.php

示例4: health

 public function health()
 {
     App::Import('ConnectionManager');
     $MPSearch = ConnectionManager::getDataSource('MPSearch');
     $elasticSearch = $MPSearch->API->cluster()->health();
     $this->set(array('elasticSearch' => $elasticSearch, '_serialize' => array('elasticSearch')));
 }
开发者ID:slachiewicz,项目名称:_mojePanstwo-API-Server,代码行数:7,代码来源:SystemController.php

示例5: beforeSave

 function beforeSave($options = array())
 {
     if ($this->data[$this->name]['type'] == 'IssueCustomField' && !empty($this->data['CustomField']['id'])) {
         $assoc_trackers = Set::extract('{n}.CustomFieldsTracker.tracker_id', $this->CustomFieldsTracker->find('all', array('conditions' => array('custom_field_id' => $this->data['CustomField']['id']))));
         $tracker_ids = empty($this->data[$this->name]['tracker_id']) ? array() : $this->data[$this->name]['tracker_id'];
         $this->__add_trackers = array_diff($tracker_ids, $assoc_trackers);
         $this->__del_trackers = array_diff($assoc_trackers, $tracker_ids);
     }
     unset($this->data[$this->name]['tracker_id']);
     App::Import('vendor', 'spyc');
     if (!empty($this->data[$this->name]['possible_values']) && $this->data[$this->name]['field_format'] == 'list') {
         if (empty($this->data[$this->name]['possible_values'][count($this->data[$this->name]['possible_values']) - 1])) {
             unset($this->data[$this->name]['possible_values'][count($this->data[$this->name]['possible_values']) - 1]);
         }
         $this->data[$this->name]['possible_values'] = Spyc::YAMLDump($this->data[$this->name]['possible_values'], true);
     } else {
         $this->data[$this->name]['possible_values'] = '--- []';
     }
     if (empty($this->data[$this->name]['min_length'])) {
         $this->data[$this->name]['min_length'] = 0;
     }
     if (empty($this->data[$this->name]['max_length'])) {
         $this->data[$this->name]['max_length'] = 0;
     }
     return true;
 }
开发者ID:nachtschatt3n,项目名称:candycane,代码行数:26,代码来源:custom_field.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->name]['type']) && $this->data[$this->name]['type'] == 'IssueCustomField' && !empty($this->data['CustomField']['id'])) {
         $this->bindModel(array('hasMany' => array('CustomFieldsTracker')), false);
         $assoc_trackers = Set::extract('{n}.CustomFieldsTracker.tracker_id', $this->CustomFieldsTracker->find('all', array('conditions' => array('custom_field_id' => $this->data['CustomField']['id']))));
         $tracker_ids = empty($this->data[$this->name]['tracker_id']) ? array() : $this->data[$this->name]['tracker_id'];
         $this->__add_trackers = array_diff($tracker_ids, $assoc_trackers ? $assoc_trackers : array());
         $this->__del_trackers = array_diff($assoc_trackers ? $assoc_trackers : array(), $tracker_ids);
     }
     unset($this->data[$this->name]['tracker_id']);
     App::Import('vendor', 'georgious-cakephp-yaml-migrations-and-fixtures/spyc/spyc');
     if (!empty($this->data[$this->name]['possible_values']) && $this->data[$this->name]['field_format'] == 'list') {
         if (empty($this->data[$this->name]['possible_values'][count($this->data[$this->name]['possible_values']) - 1])) {
             unset($this->data[$this->name]['possible_values'][count($this->data[$this->name]['possible_values']) - 1]);
         }
         $this->data[$this->name]['possible_values'] = Spyc::YAMLDump($this->data[$this->name]['possible_values'], true);
     } else {
         $this->data[$this->name]['possible_values'] = '--- []';
     }
     if (empty($this->data[$this->name]['min_length'])) {
         $this->data[$this->name]['min_length'] = 0;
     }
     if (empty($this->data[$this->name]['max_length'])) {
         $this->data[$this->name]['max_length'] = 0;
     }
     return true;
 }
开发者ID:nagumo,项目名称:candycane,代码行数:27,代码来源:CustomField.php

示例7: checkBetaKeyUsed

 public function checkBetaKeyUsed($key)
 {
     App::Import('Model', 'BetaKey');
     $this->BetaKey = new BetaKey();
     // find the key they've given
     return $this->BetaKey->find('first', array('conditions' => array('key' => $this->data['User']['beta_key'], 'email' => $this->data['User']['email'])));
 }
开发者ID:RobertWHurst,项目名称:Telame,代码行数:7,代码来源:user.php

示例8: beforeDelete

 function beforeDelete($cascade)
 {
     // Remove the extended data to be tidy.
     // First get the type id
     App::Import('Model', 'Type');
     $Type = new Type();
     $Type->recursive = -1;
     $type_record = Set::extract('/Type/id', $Type->find('first', array('fields' => array('Type.id'), 'conditions' => array('Type.alias' => $this->model->data['Node']['type']))));
     $type_id = $type_record[0];
     // Cool, now find all node schemas
     App::Import('Model', 'NodeSchema.NodeSchema');
     $NodeSchema = new NodeSchema();
     $NodeSchema->actsAs = array('Containable');
     $schemas = $NodeSchema->find('all', array('fields' => array('NodeSchema.table_name'), 'contains' => array('Type' => array('conditions' => array('Type.id' => $type_id)))));
     // Now loop through and check for records on those tables to remove
     if (is_array($schemas) && count($schemas) > 0) {
         foreach ($schemas as $schema) {
             $table_name = $schema['NodeSchema']['table_name'];
             $model = new Model(false, $table_name);
             $model->primaryKey = 'node_id';
             // set the primary key to the node_id
             if ($model->delete($this->model->data['Node']['id'], false)) {
                 return true;
             } else {
                 // return false; // There was some sort of error deleting the associated data. Do we even need this? It doesn't redirect, it stops. Have to handle the error.
             }
         }
     }
     return true;
 }
开发者ID:hgassen,项目名称:node_schema,代码行数:30,代码来源:node_schema.php

示例9: test

 function test()
 {
     App::Import('Shell', 'Shell');
     App::Import('Vendor', array('shells/sniffer_data'));
     $myShell = new SnifferDataShell(new Object());
     $myShell->initialize();
     // 	Select the method to call
     $Shell = $myShell->main($view = true, $debug = false);
 }
开发者ID:ambagasdowa,项目名称:projections,代码行数:9,代码来源:tachion.php

示例10: load

 function load($settings)
 {
     if (empty($settings)) {
         return false;
     }
     App::Import('ConnectionManager');
     $ds = ConnectionManager::getDataSource($settings);
     $this->config = $ds->config;
 }
开发者ID:rchavik,项目名称:CakePHP-Cart,代码行数:9,代码来源:cart_app_helper.php

示例11: pushHelpers

 function pushHelpers()
 {
     foreach ($this->controller->actionHelpers as $helper) {
         $_helper = ucfirst($helper);
         App::Import('Helper', $_helper);
         $_helperClassName = $helper . 'Helper';
         $this->controller->{$helper} = new $_helperClassName();
     }
 }
开发者ID:searchfirst,项目名称:Lenore,代码行数:9,代码来源:helper.php

示例12: _load

 /**
  * Loads a gateway object with the passed options
  *
  * @param string $options 
  * @return void
  * @author Dean
  */
 function _load($options = array())
 {
     App::Import('Vendor', 'AktiveMerchant', array('file' => 'aktive_merchant' . DS . 'lib' . DS . 'merchant.php'));
     if (isset($this->config['testing']) && $this->config['testing']) {
         Merchant_Billing_Base::mode('test');
     }
     $gatewayClass = 'Merchant_Billing_' . $this->config['gateway'];
     $this->gateway = new $gatewayClass($this->config);
 }
开发者ID:ricardogatica,项目名称:CakePHP-Cart,代码行数:16,代码来源:aktive_merchant_source.php

示例13: admin_export

 public function admin_export($id = null)
 {
     if (!$id) {
         $this->notice('invalid');
     }
     $this->Template->recursive = -1;
     $template = $this->Template->read(array('name', 'description', 'author', 'header', 'footer'), $id);
     if (empty($template)) {
         $this->notice('invalid');
     }
     $pattern = "/src=[\\\"']?([^\\\"']?.*(png|jpg|gif|jpeg))[\\\"']?/i";
     preg_match_all($pattern, $template['Template']['header'], $images);
     $path = TMP . 'cache' . DS . 'newsletter' . DS . 'template' . DS . $template['Template']['name'];
     $Folder = new Folder($path, 0777);
     $slash = $Folder->correctSlashFor($path);
     App::import('File');
     App::import('Folder');
     $File = new File($path . DS . 'template.xml', true, 0777);
     $imageFiles = array();
     if (!empty($images[1])) {
         foreach ($images[1] as $img) {
             $img = str_replace('/', $slash, $img);
             $img = str_replace('\\', $slash . $slash, $img);
             $imageFiles[] = $img;
             if (is_file(APP . 'webroot' . $img)) {
                 $Folder->create(dirname($path . $img), 0777);
                 $File->path = APP . 'webroot' . $img;
                 $File->copy(dirname($path . $img) . DS . basename($img));
             }
         }
     }
     $xml['template']['name'] = 'Infinitas Newsletter Template';
     $xml['template']['generator'] = 'Infinitas Template Generator';
     $xml['template']['version'] = $this->version;
     $xml['template']['template'] = $template['Template']['name'];
     $xml['template']['description'] = $template['Template']['description'];
     $xml['template']['author'] = $template['Template']['author'];
     $xml['data']['header'] = $template['Template']['header'];
     $xml['data']['footer'] = $template['Template']['footer'];
     $xml['files']['images'] = $imageFiles;
     App::Import('Helper', 'Xml');
     $Xml = new XmlHelper();
     $File->path = $path . DS . 'template.xml';
     $File->write($Xml->serialize($xml));
     App::import('Vendor', 'Zip', array('file' => 'zip.php'));
     $Zip = new CreateZipFile();
     $Zip->zipDirectory($path, null);
     $File = new File($path . DS . 'template.zip', true, 0777);
     $File->write($Zip->getZippedfile());
     $this->view = 'Media';
     $params = array('id' => 'template.zip', 'name' => $template['Template']['name'], 'download' => true, 'extension' => 'zip', 'path' => $path . DS);
     $this->set($params);
     $Folder = new Folder($path);
     $Folder->read();
     $Folder->delete($path);
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:56,代码来源:TemplatesController.php

示例14: view

 /**
  *显示页.
  */
 public function view($code)
 {
     App::Import('Vendor', 'barcode', array('file' => 'barcode.class.php'));
     $b = new BarCode();
     $this->layout = 'blank';
     $encoding = '128';
     $scale = '2';
     $mode = 'png';
     $b->barcode_print($code, $encoding, $scale, $mode);
 }
开发者ID:hobbysh,项目名称:seevia-opensource,代码行数:13,代码来源:barcodes_controller.php

示例15: beforeFilter

 function beforeFilter()
 {
     App::Import('ConnectionManager');
     App::Import('DataSource');
     App::import(array('type' => 'File', 'name' => 'Twitter.TWITTER_CONFIG', 'file' => 'config' . DS . 'core.php'));
     App::import(array('type' => 'File', 'name' => 'Twitter.TwitterSource', 'file' => 'models' . DS . 'datasources' . DS . 'twitter_source.php'));
     $TwitterConfig =& new TWITTER_CONFIG();
     ConnectionManager::create('twitter', $TwitterConfig->login);
     $this->Twitter = ConnectionManager::getDataSource('twitter');
 }
开发者ID:areisv,项目名称:cakewell,代码行数:10,代码来源:twitter_controller.php


注:本文中的App::Import方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。