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


PHP factory::create方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: get_constituency_type

function get_constituency_type()
{
    $return = false;
    $search = factory::create('search');
    $results = $search->search('constituency_type', array(array("name", "=", 'UK Parliament Constituency')));
    if (count($results) == 1) {
        $return = $results[0];
    }
    return $return;
}
开发者ID:schlos,项目名称:electionleaflets,代码行数:10,代码来源:map_uk_constituencies_to_guardian.php

示例12: lookup_constituency_names

 public static function lookup_constituency_names($postcode)
 {
     $search = factory::create('search');
     $constituencies = $search->search("australian_postcode", array(array('postcode', '=', $postcode)), 'AND', null, array(array('constituency', "ASC")));
     $result = array();
     foreach ($constituencies as $c) {
         $result[] = $c->constituency;
     }
     return $result;
 }
开发者ID:henare,项目名称:electionleaflets,代码行数:10,代码来源:australian_postcode.php

示例13: process

 function process()
 {
     // Start transaction
     $db = new DB_DataObject();
     $db->query('BEGIN');
     // Get existing constituencies
     $search = factory::create('search');
     $results = $search->search("constituency", array(array("election_id", "=", $this->election_id)), 'AND', array(array("constituency_election", "inner")), array(array('name', "ASC")));
     // Delete existing constituencies
     foreach ($results as $result) {
         if (!$result->delete()) {
             $db->query('ROLLBACK');
             die("Unable to delete constituency. Transaction rolled back.");
         }
     }
     // Delete many-to-many joins
     $query_string = 'DELETE FROM `constituency_election`
                      WHERE `election_id`=' . $this->election_id;
     if ($db->query($query_string) === false) {
         $db->query('ROLLBACK');
         die("Unable to delete constituency links. Transaction rolled back.");
     }
     // Add user supplied constituencies
     $supplied_constituencies = explode("\n", $this->data['txtConstituencies']);
     foreach ($supplied_constituencies as $constituency_name) {
         $constituency_name = trim($constituency_name);
         if ($constituency_name == '') {
             continue;
         }
         // Check for an existing constituency (from another election)
         $existing_constituency = $search->search("constituency", array(array("name", "=", $constituency_name)));
         if (count($existing_constituency) == 1) {
             $constituency = $existing_constituency[0];
         } else {
             // Create constituency
             $constituency = factory::create('constituency');
             $constituency->name = $constituency_name;
             if (!$constituency->insert()) {
                 $db->query('ROLLBACK');
                 die("Unable to add constituency. Transaction rolled back.");
             }
         }
         // Create join
         $constituency_election = factory::create('constituency_election');
         $constituency_election->constituency_id = $constituency->constituency_id;
         $constituency_election->election_id = $this->election_id;
         if (!$constituency_election->insert()) {
             $db->query('ROLLBACK');
             die("Unable to add constituency. Transaction rolled back.");
         }
     }
     $db->query('COMMIT');
     $this->bind();
     $this->render();
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:55,代码来源:adminconstituencies.php

示例14: bind

 function bind()
 {
     $this->page_title = "Election leaflets stats by party";
     $this->assign("date_since", $this->date_since);
     $search = factory::create('search');
     $parties = $search->search("party", array(array("major", "=", 1)));
     $party_rates = array();
     foreach ($parties as $party) {
         $this->assign($party->url_id . "_party_rates", $party->get_rate_values($this->date_since));
     }
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:11,代码来源:allstats.php

示例15: process

 function process()
 {
     // TODO: Duplicate detection
     if ($this->data['txtCategoryName']) {
         $category = factory::create('category');
         $category->name = $this->data['txtCategoryName'];
         if (!$category->insert()) {
             trigger_error("Unable to save category");
         }
     }
     $this->bind();
     $this->render();
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:13,代码来源:new_category.php


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