本文整理汇总了PHP中uses函数的典型用法代码示例。如果您正苦于以下问题:PHP uses函数的具体用法?PHP uses怎么用?PHP uses使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uses函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getrss
function getrss()
{
uses('Sanitize');
Configure::write('debug', '0');
//turn debugging off; debugging breaks ajax
$this->layout = 'ajax';
$mrClean = new Sanitize();
$limit = 5;
$start = 0;
if (empty($this->params['form']['url'])) {
die('Incorrect use');
}
$url = $this->params['form']['url'];
if (!empty($this->params['form']['limit'])) {
$limit = $mrClean->paranoid($this->params['form']['limit']);
}
if (!empty($this->params['form']['start'])) {
$start = $mrClean->paranoid($this->params['form']['start']);
}
$feed = $this->Simplepie->feed_paginate($url, (int) $start, (int) $limit);
$out['totalCount'] = $feed['quantity'];
$out['title'] = $feed['title'];
$out['image_url'] = $feed['image_url'];
$out['image_width'] = $feed['image_width'];
$out['image_height'] = $feed['image_height'];
foreach ($feed['items'] as $item) {
$tmp['title'] = strip_tags($item->get_title());
$tmp['url'] = strip_tags($item->get_permalink());
$tmp['description'] = strip_tags($item->get_description(), '<p><br><img><a><b>');
$tmp['date'] = strip_tags($item->get_date('d/m/Y'));
$out['items'][] = $tmp;
}
$this->set('json', $out);
}
开发者ID:vad,项目名称:taolin,代码行数:34,代码来源:wrappers_controller.php
示例2: XpFrameworkCircularReferenceTest
public function XpFrameworkCircularReferenceTest()
{
// try to load class
uses('xpbug.circularreference.XPBugCircularReference');
// we are still here so no fatal error
return $this->assertTrue(true);
}
开发者ID:Gamepay,项目名称:xp-contrib,代码行数:7,代码来源:XPBugCircularReferenceTest.class.php
示例3: purchase_product
function purchase_product()
{
// Clean up the post
uses('sanitize');
$clean = new Sanitize();
$clean->paranoid($_POST);
// Check if we have an active cart, if there is no order_id set, then lets create one.
if (!isset($_SESSION['Customer']['order_id'])) {
$new_order = array();
$new_order['Order']['order_status_id'] = 0;
// Get default shipping & payment methods and assign them to the order
$default_payment = $this->Order->PaymentMethod->find(array('default' => '1'));
$new_order['Order']['payment_method_id'] = $default_payment['PaymentMethod']['id'];
$default_shipping = $this->Order->ShippingMethod->find(array('default' => '1'));
$new_order['Order']['shipping_method_id'] = $default_shipping['ShippingMethod']['id'];
// Save the order
$this->Order->save($new_order);
$order_id = $this->Order->getLastInsertId();
$_SESSION['Customer']['order_id'] = $order_id;
global $order;
$order = $new_order;
}
// Add the product to the order from the component
$this->OrderBase->add_product($_POST['product_id'], $_POST['product_quantity']);
global $config;
$content = $this->Content->read(null, $_POST['product_id']);
$this->redirect('/product/' . $content['Content']['alias'] . $config['URL_EXTENSION']);
}
开发者ID:risnandar,项目名称:testing,代码行数:28,代码来源:cart_controller.php
示例4: GetLogger
/**
* Fetches a configured logger.
*
* @param string $name Name of the logger.
* @return array An array of loggers
*/
public static function GetLogger($name)
{
if (isset(self::$_loggers[$name])) {
return self::$_loggers[$name];
} else {
$conf = Config::Get('logger');
if (isset($conf->items[$name])) {
if (!$conf->items[$name]->enabled) {
return null;
}
$logtypes = $conf->items[$name]->output;
$target = $conf->items[$name]->target;
$enabled = $conf->items[$name]->enabled;
$types = explode(',', $logtypes);
foreach ($types as $type) {
uses("system.app.driver.logger.{$type}");
$class = $type . "Logger";
$logger = new $class($type, $target, $conf->items[$name]);
self::$_loggers[$name][] = $logger;
}
return self::$_loggers[$name];
}
return null;
}
}
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:31,代码来源:logger.php
示例5: import
function import($sFile)
{
if (!$this->bSpycReady) {
return self::SPYC_CLASS_NOT_FOUND;
}
if (!file_exists($sFile)) {
return self::YAML_FILE_NOT_FOUND;
}
$this->aTables = SPYC::YAMLload(file_get_contents($sFile));
if (!is_array($this->aTables)) {
return self::YAML_FILE_IS_INVALID;
}
uses('model' . DS . 'model');
$oDB = $this->oDb;
$aAllowedTables = $oDB->listSources();
foreach ($this->aTables as $table => $records) {
if (!in_array($oDB->config['prefix'] . $table, $aAllowedTables)) {
return self::TABLE_NOT_FOUND;
}
$temp_model = new Model(false, $table);
foreach ($records as $record_num => $record_value) {
if (!isset($record_value['id'])) {
$record_value['id'] = $record_num;
}
if (!$temp_model->save($record_value)) {
return array('error' => array('table' => $table, 'record' => $record_value));
}
}
}
return true;
}
开发者ID:gildonei,项目名称:candycane,代码行数:31,代码来源:fixtures.php
示例6: Run
/**
* Runs a screen.
*
* @param string $which Which screen to run, "before" or "after"
* @param Controller $controller The controller
* @param AttributeReader $method_meta The method metadata
* @param Array $data Array of data that the screen(s) can add to.
*/
public static function Run($which, $controller, $method_meta, &$data, &$args)
{
$c = $controller->metadata->{$which};
$m = $method_meta->{$which};
if (!$c) {
$c = new AttributeReader();
}
if (!$m) {
$m = new AttributeReader();
}
$screens = $c->merge($m);
foreach ($screens as $name => $screen) {
if (!$screen->ignore) {
if (isset(self::$_screens[$name])) {
$s = self::$_screens[$name];
} else {
uses('screen.' . $name);
$class = $name . 'Screen';
$s = new $class();
self::$_screens[$name] = $s;
}
$s->{$which}($controller, $screen, $data, $args);
}
}
}
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:33,代码来源:screen.php
示例7: GetManager
/**
* Fetches a named database from the connection pool.
*
* @param string $name Name of the database to fetch from the connection pool.
* @return Database The named database.
*/
public static function GetManager($name)
{
if (isset(self::$_managers[$name]))
return self::$_managers[$name];
else
{
$conf=Config::Get('cloud');
if (isset($conf->dsn->items[$name]))
{
$dsn=$conf->dsn->items[$name]->storage;
$matches=array();
if (preg_match_all('#([a-z0-9]*)://([^@]*)@(.*)#',$dsn,$matches))
{
$driver=$matches[1][0];
$auth=$matches[2][0];
$secret=$matches[3][0];
uses('system.cloud.driver.storage.'.$driver);
$class=$driver."Driver";
$storage=new $class($auth,$secret);
self::$_managers[$name]=$storage;
return $storage;
}
}
throw new Exception("Cannot find storage named '$name' in Config.");
}
}
开发者ID:nikels,项目名称:HeavyMetal,代码行数:37,代码来源:storage_manager.php
示例8: getProductById
function getProductById($product_id)
{
$sql = "SELECT p.* FROM {$this->table_prefix}products p WHERE p.id=" . $product_id;
$result = $this->dbstuff->GetRow($sql);
if (empty($result) || !$result) {
return false;
}
$result['pubdate'] = @date("Y-m-d", $result['created']);
if (!empty($result['picture'])) {
$result['imgsmall'] = "../" . pb_get_attachmenturl($result['picture']) . ".small.jpg";
$result['imgmiddle'] = "../" . pb_get_attachmenturl($result['picture']) . ".middle.jpg";
$result['image'] = "../" . pb_get_attachmenturl($result['picture']);
$result['image_url'] = rawurlencode($result['picture']);
} else {
$result['image'] = pb_get_attachmenturl('', '', 'middle');
}
if (!empty($result['tag_ids'])) {
uses("tag");
$tag = new Tags();
$tag_res = $tag->getTagsByIds($result['tag_ids']);
if (!empty($tag_res)) {
$tags = null;
foreach ($tag_res as $key => $val) {
$tags .= '<a href="product/list.php?do=search&q=' . urlencode($val) . '" target="_blank">' . $val . '</a> ';
}
$result['tag'] = $tags;
unset($tags, $tag_res, $tag);
}
}
$this->info = $result;
return $result;
}
开发者ID:vuong93st,项目名称:w-game,代码行数:32,代码来源:product.php
示例9: beforeFilter
function beforeFilter()
{
header('Content-type: text/html; charset="utf-8"');
uses('L10n');
//backend is protected
if (!empty($this->params['admin']) && $this->params['admin'] == 1) {
$this->layout = "admin";
if (isset($this->Auth)) {
$this->Auth->userModel = 'User';
$this->Auth->fields = array('username' => 'email', 'password' => 'password');
$this->Auth->loginAction = '/admin/users/login';
$this->Auth->loginRedirect = '/admin/users/';
$this->Auth->autoRedirect = true;
$this->user = $this->Auth->user();
if (empty($this->user) && $this->RequestHandler->isAjax()) {
$this->render(null, 'ajax', APP . 'views/elements/ajax_login_message.ctp');
}
$this->set('user', $this->user);
$this->_setAdminMenu();
}
if ($this->name == 'Users' && $this->action == 'admin_login') {
$this->layout = 'admin_login';
}
} else {
$this->Auth->allow();
}
}
开发者ID:hafizubikm,项目名称:bakeme,代码行数:27,代码来源:app_controller.php
示例10: Search
function Search($firstcount, $displaypg)
{
global $cache_types;
uses("space", "industry", "area");
$space = new Space();
$area = new Areas();
$industry = new Industries();
$cache_options = cache_read('typeoption');
$area_s = $space->array_multi2single($area->getCacheArea());
$industry_s = $space->array_multi2single($area->getCacheArea());
$result = $this->findAll("*,name AS title,content AS digest", null, null, $this->orderby, $firstcount, $displaypg);
while (list($keys, $values) = each($result)) {
$result[$keys]['typename'] = $cache_types['productsort'][$values['sort_id']];
$result[$keys]['thumb'] = pb_get_attachmenturl($values['picture'], '', 'small');
$result[$keys]['pubdate'] = df($values['begin_time']);
if (!empty($result[$keys]['area_id'])) {
$r1 = $area_s[$result[$keys]['area_id']];
}
if (!empty($result[$keys]['cache_companyname'])) {
$r2 = "<a href='" . $space->rewrite($result[$keys]['cache_companyname'], $result[$keys]['company_id']) . "'>" . $result[$keys]['cache_companyname'] . "</a>";
}
if (!empty($r1) || !empty($r2)) {
$result[$keys]['extra'] = implode(" - ", array($r1, $r2));
}
$result[$keys]['url'] = $this->getPermaLink($values['id']);
}
return $result;
}
开发者ID:renduples,项目名称:alibtob,代码行数:28,代码来源:product.php
示例11: testUses
/**
* test uses()
*
* @access public
* @return void
*/
function testUses()
{
$this->assertFalse(class_exists('Security'));
$this->assertFalse(class_exists('Sanitize'));
uses('Security', 'Sanitize');
$this->assertTrue(class_exists('Security'));
$this->assertTrue(class_exists('Sanitize'));
}
开发者ID:Jaciss,项目名称:wildflower,代码行数:14,代码来源:basics.test.php
示例12: Document
/**
* Creates a finder for documents of a given name.
* @static
* @param $document_name
* @return Finder
*/
public static function Document($document_name)
{
$document_name = str_replace('/', '.', $document_name);
uses("document.{$document_name}");
$parts = explode('.', $document_name);
$class = str_replace('_', '', array_shift($parts));
$instance = new $class();
return $instance->doc_db->create_finder($instance);
}
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:15,代码来源:finder.php
示例13: Model
public static function Model($model)
{
//$model=str_replace('.','/',$model);
uses('model.' . $model);
$parts = explode('.', $model);
$class = str_replace('_', '', $parts[1]);
$instance = new $class();
return new SOLRFilter($instance, $class, false);
}
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:9,代码来源:solr_filter.php
示例14: __construct
/**
* Instantiate the fixture.
*
* @param object Cake's DBO driver (e.g: DboMysql).
*
* @access public
*/
function __construct(&$db)
{
$this->db =& $db;
$this->init();
if (!class_exists('cakeschema')) {
uses('model' . DS . 'schema');
}
$this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test_suite'));
}
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:16,代码来源:cake_test_fixture.php
示例15: admin_upload
function admin_upload()
{
uses('folder');
$folder = new Folder($this->directory, false, 0755);
$upload = array();
$copyright_type = $this->Copyright->generateList();
$this->set(compact('copyright_type'));
if (isset($this->data) && $this->data['Image']['filename']['error'] == 0) {
// Check that Filetype is valid
if (!in_array($this->data['Image']['filename']['type'], $this->allowedTypes)) {
$this->Session->setFlash('Invalid File type: ' . $this->data['Image']['filename']['type']);
return false;
}
$valid_ext = $this->getExt($this->data['Image']['filename']['type']);
// Explode file name and extention
$myfile = $this->FileOps->explodeFilename($this->data['Image']['filename']['name']);
if (!$valid_ext == $myfile['ext']) {
$this->Session->setFlash('File extention does not match mimetype. Please check this file is a valid' . $this->data['Image']['filename']['type'] . ' file.');
break;
}
// Lets get the metadata first
$upload['type'] = $this->data['Image']['filename']['type'];
$upload['filesize'] = $this->data['Image']['filename']['size'];
$upload['alt'] = $this->data['Image']['alt'];
$upload['filename'] = $myfile['filename'];
$upload['copyright_id'] = $this->data['Image']['copyright_id'];
$upload['copyright_owner'] = $this->data['Image']['copyright_owner'];
// The temporary file we need to copy once uploaded.
$upload['tmp'] = $this->data['Image']['filename']['tmp_name'];
if (!file_exists($this->directory . $upload['filename'] . '.' . $myfile['ext'])) {
if (!($moved = $this->FileOps->movefile($this->directory, $upload['tmp'], $upload['filename'] . '.' . $myfile['ext']))) {
$this->Session->setFlash('File system save failed.');
return false;
} else {
$this->Image->create();
$this->Image->save($upload);
$this->Session->setFlash('Image successfuly uploaded');
foreach ($this->thumbsize as $thumb => $settings) {
$thumbfile = $myfile['filename'] . '.' . $thumb . '.' . $myfile['ext'];
if (!$this->createthumb($this->directory . $upload['filename'] . '.' . $myfile['ext'], $this->directory . $thumbfile, $settings['width'], $settings['width'])) {
// #TODO: validation does not seem to work.
//$this->Session->setFlash('Thumb failed');
//return false;
}
}
}
} else {
$this->Session->setFlash('File already exists.');
return false;
}
} else {
if ($this->data['Image']['filename']['error'] == 4) {
print_r('No File Selected');
}
}
}
开发者ID:paulToro,项目名称:webrocket,代码行数:56,代码来源:images_controller.php
示例16: smarty_block_feed
/**
* [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
* The contents of this file are subject to the License; you may not use this file except in compliance with the License.
*
* @version $Revision: 2075 $
*/
function smarty_block_feed($params, $content, &$smarty, &$repeat)
{
$conditions = array();
$param_count = count($smarty->_tag_stack);
if (empty($params['name'])) {
$params['name'] = "feed";
}
if (class_exists("Services")) {
$service = new Services();
$service_controller = new Service();
} else {
uses("service");
$service = new Services();
$service_controller = new Service();
}
$orderby = array();
require CACHE_PATH . "cache_type.php";
if (isset($params['type'])) {
$conditions[] = "type='" . $params['type'] . "'";
}
if (isset($params['typeid'])) {
$conditions[] = "type_id='" . $params['typeid'] . "'";
}
if (isset($params['id'])) {
$conditions[] = "id='" . $params['id'] . "'";
}
if (isset($params['orderby'])) {
$orderby[] = trim($params['orderby']);
} else {
$orderby[] = "id DESC ";
}
$service->setOrderby($orderby);
$service->setCondition($conditions);
$limit = $offset = 0;
if (isset($params['row'])) {
$limit = $params['row'];
}
if (isset($params['start'])) {
$offset = $params['start'];
}
$service->setLimitOffset($offset, $limit);
$sql = "SELECT * FROM {$service->table_prefix}feeds " . $service->getCondition() . $service->getOrderby() . $service->getLimitOffset();
$result = $service->GetArray($sql);
$return = $link_title = null;
if (!empty($result)) {
$i_count = count($result);
for ($i = 0; $i < $i_count; $i++) {
$data = unserialize($result[$i]['data']);
foreach ($data as $val) {
$link_title .= $val;
}
$return .= str_replace(array("[link:title]"), array($link_title), $content);
}
}
return $return;
}
开发者ID:renduples,项目名称:alibtob,代码行数:62,代码来源:block.feed.php
示例17: __construct
function __construct($config = null)
{
if ($config != null) {
parent::__construct($config);
}
uses('xml');
vendor('snoopy/snoopy');
$this->xml = new XML();
$this->Snoopy = new Snoopy();
}
开发者ID:stuartloxton,项目名称:cakephp-ytdatasource,代码行数:10,代码来源:youtube_source.php
示例18: copyDemoproductImages
/**
* Copy demo products directory to webroot
*/
public function copyDemoproductImages()
{
uses('folder');
$path = APP . 'webroot' . DS . 'img' . DS . 'uploads' . DS;
$folder =& new Folder($path);
@$folder->delete($path);
$backup = APP . 'docs' . DS . 'uploads' . DS;
$folder =& new Folder($backup);
@$folder->copy($path);
}
开发者ID:yamaguchitarou,项目名称:bakesale,代码行数:13,代码来源:installer.php
示例19: Init
public static function Init()
{
$profiler=Config::$environment_config->profiler;
if ((self::$_profiler==null) && ($profiler!=null) && ($profiler!="none"))
{
uses('sys.utility.profilers.'.$profiler);
$class=$profiler."Profiler";
self::$_profiler=new $class();
}
}
开发者ID:jawngee,项目名称:Thor,代码行数:11,代码来源:profiler.php
示例20: arreglar_tipoinstits
private function arreglar_tipoinstits()
{
App::import('Vendor', 'depura_tipoinstit/main');
uses('model' . DS . 'datasources' . DS . 'datasource');
config('database');
$this->autoRender = false;
//conecto con la BD de cake default
$this->db = new DATABASE_CONFIG();
$depurador = new DepuraTipoinstits($this->db->default);
$depurador->main();
}
开发者ID:romanmussi,项目名称:rfietp,代码行数:11,代码来源:depuradores_controller.php
注:本文中的uses函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论