• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP factory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: fetch

 public function fetch($delete = false)
 {
     $oImap = imap_open('{' . $this->mail_server . ':993/imap/ssl/notls/novalidate-cert}', $this->username, $this->password);
     $oMailboxStatus = imap_check($oImap);
     $aMessages = imap_fetch_overview($oImap, "1:{$oMailboxStatus->Nmsgs}");
     $validMessages = array();
     foreach ($aMessages as $oMessage) {
         print "Trying message '" . $oMessage->subject . "'";
         $fileContent = $fileType = '';
         $geocoder = factory::create('geocoder');
         $postCode = $geocoder->extract_postcode($oMessage->subject);
         $fromName = null;
         $fromEmail = null;
         if (strpos($oMessage->from, '<')) {
             $split = split('<', $oMessage->from);
             //name - make sure name not an email address
             $fromName = trim($split[0]);
             if (valid_email($fromName)) {
                 $fromName = null;
             }
             //email
             $fromEmail = trim(str_replace('>', '', $split[1]));
         } else {
             $fromEmail = $oMessage->from;
         }
         $images = array();
         $messageStructure = imap_fetchstructure($oImap, $oMessage->msgno);
         if (isset($messageStructure->parts)) {
             $partNumber = 0;
             foreach ($messageStructure->parts as $oPart) {
                 $partNumber++;
                 if ($oPart->subtype == 'PLAIN' && !$postCode) {
                     $messageContent = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     if ($oPart->encoding == 4) {
                         $messageContent = quoted_printable_decode($messageContent);
                     }
                     $postCode = geocoder::extract_postcode($messageContent);
                 } elseif ($oPart->encoding == 3 && in_array($oPart->subtype, array('JPEG', 'PNG'))) {
                     $oImage = null;
                     $encodedBody = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     $fileContent = base64_decode($encodedBody);
                     $oImage = imagecreatefromstring($fileContent);
                     if (imagesx($oImage) > $this->min_import_size && imagesy($oImage) > $this->min_import_size) {
                         array_push($images, $oImage);
                     }
                     $fileType = strtolower($oPart->subtype);
                 }
             }
         }
         //add to the messages array
         array_push($validMessages, array('postcode' => $postCode, 'images' => $images, 'file_type' => $fileType, 'from_address' => $fromAddress, 'from_email' => $fromEmail, 'from_name' => $fromName));
         if ($delete) {
             imap_delete($oImap, $oMessage->msgno);
         }
     }
     imap_close($oImap, CL_EXPUNGE);
     $this->messages = $validMessages;
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:58,代码来源:mail_image.php


示例2: can

 /**
  * Whether we can perform certain action
  *
  * @param mixed $action_code_or_id
  * @return boolean
  */
 public static function can($action_code_or_id)
 {
     if (self::$cache_actions === null) {
         self::$cache_actions = factory::model('numbers_backend_system_controller_model_actions')->get();
     }
     if (is_string($action_code_or_id)) {
         foreach (self::$cache_actions as $k => $v) {
             if ($v['sm_cntractn_code'] == $action_code_or_id) {
                 $action_code_or_id = $k;
                 break;
             }
         }
     }
     if (!isset(self::$cache_actions[$action_code_or_id])) {
         throw new Exception('Unknown action!');
     }
     $permissions = application::get(['controller', 'acl', 'permissions']);
     $start = $action_code_or_id;
     do {
         // see if we have permission
         if (empty($permissions[$start])) {
             break;
         }
         // we need to check permission on a parent
         if (!empty(self::$cache_actions[$start]['sm_cntractn_parent_id'])) {
             $start = self::$cache_actions[$start]['sm_cntractn_parent_id'];
         } else {
             // exit if there's no parent
             return true;
         }
     } while (1);
     return false;
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:39,代码来源:controller.php


示例3: __construct

 /**
  * Constructing cache object
  *
  * @param string $cache_link
  * @param string $class
  */
 public function __construct($cache_link = null, $class = null)
 {
     // if we need to use default link from application
     if (empty($cache_link)) {
         $cache_link = application::get(['flag', 'global', 'cache', 'default_cache_link']);
         if (empty($cache_link)) {
             throw new Exception('You must specify cache link and/or class!');
         }
     }
     // get object from factory
     $temp = factory::get(['cache', $cache_link]);
     // if we have class
     if (!empty($class) && !empty($cache_link)) {
         // replaces in case we have it as submodule
         $class = str_replace('.', '_', trim($class));
         // if we are replacing database connection with the same link we
         // need to manually close connection
         if (!empty($temp['object']) && $temp['class'] != $class) {
             $object = $temp['object'];
             $object->close();
             unset($this->object);
         }
         $this->object = new $class($cache_link);
         // putting every thing into factory
         factory::set(['cache', $cache_link], ['object' => $this->object, 'class' => $class]);
     } else {
         if (!empty($temp['object'])) {
             $this->object = $temp['object'];
         } else {
             throw new Exception('You must specify cache link and/or class!');
         }
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:39,代码来源:cache.php


示例4: getInstance

 /**
  * Get the unique cache instance
  *
  * @param array $cfg Config for the cache instance
  * @return cache_abstract The instance
  */
 public static function getInstance(array $cfg = array())
 {
     if (!self::$cfg) {
         self::$cfg = new config(factory::loadCfg(__CLASS__));
     }
     return factory::get('cache_' . self::$cfg->use, $cfg);
 }
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:13,代码来源:cache.class.php


示例5: query

    public function query($options = [])
    {
        $model = factory::model($options['model']);
        $db = $model->db_object();
        $where = '';
        if (!empty($options['where'])) {
            $where = 'AND ' . $db->prepare_condition($options['where']);
        }
        $ts = $db->full_text_search_query($options['fields'], $options['search_text'] . '');
        $fields = $options['fields'];
        $sql_pk = '';
        // we automatically include main pk into a query
        if (!in_array($options['pk'], $options['fields'])) {
            // in_array($options['pk'], $model->pk) &&
            $fields[] = $options['pk'];
            // we need to include integer types to the query
            $temp = intval($options['search_text']);
            if ($model->columns[$options['pk']]['php_type'] == 'integer' && $temp != 0) {
                $sql_pk .= " OR {$options['pk']} = " . (int) $options['search_text'];
            }
        }
        $fields[] = $ts['rank'];
        $fields = implode(', ', $fields);
        $tmp = <<<TTT
\t\t\tSELECT
\t\t\t\t{$fields}
\t\t\tFROM [table[{$options['model']}]] a
\t\t\tWHERE 1=1
\t\t\t\t\t{$where}
\t\t\t\t\tAND (({$ts['where']}){$sql_pk})
\t\t\tORDER BY {$ts['orderby']} DESC, {$options['fields'][0]}
\t\t\tLIMIT 11
TTT;
        return $tmp;
    }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:35,代码来源:datasource.php


示例6: example_postcode

 public static function example_postcode()
 {
     $election_id = get_election_id($election_id);
     $search = factory::create('search');
     $result = $search->search("australian_postcode", array(array('election_id', '=', $election_id)), null, null, null, 1);
     return $result[0]->postcode;
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:7,代码来源:australian_postcode.php


示例7: __construct

 /**
  * Constructing crypt object
  *
  * @param string $db_link
  * @param string $class
  */
 public function __construct($crypt_link = null, $class = null, $options = [])
 {
     // if we need to use default link from application
     if ($crypt_link == null) {
         $crypt_link = application::get(['flag', 'global', 'crypt', 'default_crypt_link']);
         if (empty($crypt_link)) {
             throw new Exception('You must specify crypt link!');
         }
     }
     // get object from factory
     $temp = factory::get(['crypt', $crypt_link]);
     // if we have class
     if (!empty($class) && !empty($crypt_link)) {
         // replaces in case we have it as submodule
         $class = str_replace('.', '_', trim($class));
         // creating new class
         unset($this->object);
         $this->object = new $class($crypt_link, $options);
         factory::set(['crypt', $crypt_link], ['object' => $this->object, 'class' => $class]);
     } else {
         if (!empty($temp['object'])) {
             $this->object = $temp['object'];
         } else {
             throw new Exception('You must specify crypt link and/or class!');
         }
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:33,代码来源:crypt.php


示例8: lookup_constituency

 private function lookup_constituency($postcode)
 {
     $cache = cache::factory();
     $cached = $cache->get('twfy' . $postcode);
     if (isset($cached) && $cached !== false && $cached != '') {
         return $cached;
     } else {
         if (COUNTRY_CODE_TLD == "uk") {
             $twfy = factory::create('twfy');
             $twfy_constituency = $twfy->query('getConstituency', array('output' => 'php', 'postcode' => $postcode, 'future' => 'yes_please'));
             $twfy_constituency = unserialize($twfy_constituency);
             $success = $cache->set('twfy' . $postcode, $twfy_constituency);
             $twfy_constituency = array($twfy_constituency["name"]);
         } else {
             if (COUNTRY_CODE_TLD == "au") {
                 $australian_postcode = factory::create("australian_postcode");
                 return $australian_postcode->lookup_constituency_names($postcode);
             } else {
                 $success = false;
             }
         }
         if ($success && isset($twfy_constituency) && $twfy_constituency != '' && $twfy_constituency != false) {
             return $twfy_constituency;
         } else {
             return false;
         }
     }
 }
开发者ID:henare,项目名称:electionleaflets,代码行数:28,代码来源:constituencies.php


示例9: get_leaflets

function get_leaflets($email_alert)
{
    if (ALERT_DEBUG > 0) {
        print $email_alert->type . "\n";
        print "frequency : " . $email_alert->frequency_hours . "\n";
    }
    $results = array();
    $search = factory::create('search');
    $time = time() - 60 * 60 * $email_alert->frequency_hours;
    $time = mysql_date($time);
    //do we have any matching leaflets?
    if ($email_alert->type == 'attack') {
        $results = $search->search('leaflet', array(array('leaflet_party_attack.party_id', '=', $email_alert->parent_id), array('leaflet.date_uploaded', '>=', $time), array('leaflet.live', '=', 1)), 'AND', array(array('leaflet_party_attack', 'inner')));
    } else {
        if ($email_alert->type == 'party') {
            $results = $search->search('leaflet', array(array('leaflet.publisher_party_id', '=', $email_alert->parent_id), array('leaflet.date_uploaded', '>=', $time), array('leaflet.live', '=', 1)));
        } else {
            if ($email_alert->type == 'constituency') {
                $results = $search->search('leaflet', array(array('leaflet_constituency.constituency_id', '=', $email_alert->parent_id), array('leaflet.date_uploaded', '>=', $time), array('leaflet.live', '=', 1)), 'AND', array(array('leaflet_constituency', 'inner')));
            } else {
                if ($email_alert->type == 'category') {
                    $results = $search->search('leaflet', array(array('leaflet_category.category_id', '=', $email_alert->parent_id), array('leaflet.date_uploaded', '>=', $time), array('leaflet.live', '=', 1)), 'AND', array(array('leaflet_category', 'inner')));
                }
            }
        }
    }
    return $results;
}
开发者ID:schlos,项目名称:electionleaflets,代码行数:28,代码来源:alertomatic.php


示例10: __construct

 public function __construct()
 {
     require_once _CORE_ROOT . 'factory.class.php';
     require_once _CORE_ROOT . 'cexception.class.php';
     //require_once(_CORE_ROOT.'error.class.php');
     $this->benchmark = factory::createBenchmarkObject();
     $this->db = factory::createDbObject();
     $this->tpl = factory::createTplObject($this->benchmark);
     $this->input = factory::createInputObject();
     $this->log = factory::createLogger();
     factory::createUtil();
     if (_MEMCACHE_ENABLE) {
         $this->memcache = factory::createMemcacheObject();
     }
     if (_DEBUG === 'Y') {
         ini_set('display_errors', 1);
         error_reporting(E_ALL);
         $this->debug = factory::createDebugObject($this->benchmark);
     } else {
         if (_DEBUG === 'N') {
             ini_set('display_errors', 0);
             error_reporting(E_ALL ^ E_NOTICE);
             $this->debug = factory::createNoDebugObject();
         } else {
             //nothing todo ;
         }
     }
 }
开发者ID:ronalfei,项目名称:CodeAnt,代码行数:28,代码来源:codeant.class.php


示例11: bind

 function bind()
 {
     //get the leaflet
     $search = factory::create("search");
     $result = $search->search("leaflet", array(array("leaflet_id", "=", $this->leaflet_id), array('live', '=', 1)), 'AND', array(array("party", "inner")));
     $leaflet = null;
     if (count($result) != 1) {
         throw_404();
     } else {
         $leaflet = $result[0];
     }
     //get images
     $leaflet_images = $search->search("leaflet_image", array(array("leaflet_id", "=", $this->leaflet_id)), 'AND', null, array(array("sequence", "ASC")));
     //get categories
     $leaflet_categories = $search->search("category", array(array("leaflet_category.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_category", 'inner')));
     //get tags
     $leaflet_tags = $search->search("tag", array(array("leaflet_tag.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_tag", 'inner')));
     //get parties attacked
     $leaflet_parties_attacked = $search->search("party", array(array("leaflet_party_attack.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_party_attack", 'inner')));
     //get constituencies
     $leaflet_constituencies = $search->search("constituency", array(array("leaflet_constituency.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_constituency", 'inner')));
     //js
     $this->onloadscript = "showMap('" . MAP_PROVIDER . "', " . number_format($leaflet->lng, 2) . ", " . number_format($leaflet->lat, 2) . ");";
     //assign
     $this->page_title = $leaflet->title . " (an election leaflet published by " . $leaflet->party_name . ")";
     $this->has_map = true;
     $this->assign("leaflet", $leaflet);
     $this->assign("leaflet_images", $leaflet_images);
     $this->assign("leaflet_categories", $leaflet_categories);
     $this->assign("leaflet_tags", $leaflet_tags);
     $this->assign("constituency", $leaflet_constituencies[0]);
     $this->assign("leaflet_parties_attacked", $leaflet_parties_attacked);
 }
开发者ID:henare,项目名称:electionleaflets,代码行数:33,代码来源:leaflet.php


示例12: set_application

 private function set_application()
 {
     $application = session_read('application');
     if (!isset($application)) {
         $application = factory::create('application');
     }
     $this->application = $application;
 }
开发者ID:GetUp,项目名称:Election-Leaflet-Project-Australia,代码行数:8,代码来源:pagebase.php


示例13: method

 /**
  * Call validator method
  *
  * @param string $method
  * @param array $params
  * @param array $options
  * @param array $neighbouring_values
  * @return array
  */
 public static function method($method, $value, $params = [], $options = [], $neighbouring_values = [])
 {
     $method = factory::method($method);
     $params = $params ?? [];
     $params['options'] = $options;
     $params['neighbouring_values'] = $neighbouring_values;
     return factory::model($method[0], true)->{$method[1]}($value, $params);
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:17,代码来源:base.php


示例14: bind

 function bind()
 {
     $this->page_title = "Election leaflets by category";
     $search = factory::create('search');
     //get top parties
     $categories = $search->search_cached("category", array(array("1", "=", "1")), "AND", null, array(array("name", "ASC")));
     $this->assign("categories", $categories);
 }
开发者ID:henare,项目名称:electionleaflets,代码行数:8,代码来源:categories.php


示例15: add

 /**
  * Add library to the application
  * 
  * @param string $library
  */
 public static function add($library)
 {
     $connected = application::get('flag.global.library.' . $library . '.connected');
     if (!$connected) {
         factory::submodule('flag.global.library.' . $library . '.submodule')->add();
         application::set('flag.global.library.' . $library . '.connected', true);
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:13,代码来源:library.php


示例16: bind

 function bind()
 {
     $this->page_title = "Election leaflets by category";
     $search = factory::create('search');
     $election_id = get_election_id();
     // Get categories
     $categories = $search->search_cached("category", array(array("category_election.election_id", "=", $election_id)), 'AND', array(array("category_election", "inner")), array(array('name', "ASC")));
     $this->assign("categories", $categories);
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:9,代码来源:categories.php


示例17: getInstance

	/**
	 * Get the response object according to the requested out
	 *
	 * @return response_abstract
	 */
	public static function getInstance() {
		if (self::$proxy)
			return self::$proxy;
		if (!self::$inst) {
			self::$inst = factory::get('response_'.request::getResponseName());
			self::$inst->setContentType(request::get('out'));
		}
		return self::$inst;
	}
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:14,代码来源:response.class.php


示例18: bind

 function bind()
 {
     $this->page_title = "Election leaflets by tag";
     $search = factory::create('search');
     $tag = factory::create("tag");
     $tag_count = 250;
     $weighted_tags = $tag->get_weighted_tags($tag_count);
     $this->assign("weighted_tags", $weighted_tags);
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:9,代码来源:tags.php


示例19: bind

 function bind()
 {
     $this->page_title = "Election leaflets by party";
     $search = factory::create('search');
     //get top parties
     $election_id = get_election_id();
     $parties = $search->search_cached("party", array(array("party_election.election_id", "=", $election_id)), "AND", array(array("party_election", "inner")), array(array("name", "ASC")));
     $this->assign("parties", $parties);
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:9,代码来源:parties.php


示例20: __construct

 /**
  * Mysql构造函数
  *
  * @param string $host
  * @param string $user
  * @param string $password
  * @param string $db_name
  * @param string $charset
  */
 public function __construct($host, $port, $user, $password, $db_name, $charset)
 {
     $this->host = $host;
     $this->port = $port;
     $this->user = $user;
     $this->db_name = $db_name;
     $this->charset = $charset;
     $this->password = $password;
     $this->dbdebug = factory::createDBDebugObject();
 }
开发者ID:ronalfei,项目名称:CodeAnt,代码行数:19,代码来源:mysql.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP factura_cliente类代码示例发布时间:2022-05-23
下一篇:
PHP fURL类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap