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


PHP Convert类代码示例

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


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

示例1: testInvalidMap

 /**
  * @return void
  */
 public function testInvalidMap()
 {
     $this->setExpectedException('Exception');
     $handler = new Convert('[dummy]');
     $record = $this->getMock('Migration\\ResourceModel\\Record', [], [], '', false);
     $record2 = $this->getMockBuilder('Migration\\ResourceModel\\Record')->disableOriginalConstructor()->getMock();
     $handler->handle($record, $record2, 'dummy');
 }
开发者ID:Mohitsahu123,项目名称:data-migration-tool-ce,代码行数:11,代码来源:ConvertTest.php

示例2: AddCompanyStatus

 public function AddCompanyStatus($arg = false)
 {
     $model = $this->model;
     $arrayobject = $model->AddCompanyStatus($arg);
     $ObjectDTO = new Convert();
     $companies = $ObjectDTO->toObject($arrayobject);
     $this->View->msg = $companies;
     $this->View->render('places_Ive_searched/index');
 }
开发者ID:Smeltvig,项目名称:PHP-MVC,代码行数:9,代码来源:places_Ive_searched.php

示例3: doUpload

 public function doUpload()
 {
     $id = $_POST['id'];
     $duration = $_POST['duration'];
     $sn = $_POST['sn'];
     $isLast = $_POST['last'];
     $mysql = new DbMysql();
     $dashfile = new DashFile($id, $sn);
     $convert = new Convert($dashfile);
     if ($isLast == 1) {
         if (!$mysql->connect()) {
             return "ERROR: Sql server connect error!\n";
         }
         if (!$mysql->updateStatus($id, '1')) {
             return "ERROR: Sql INSERT error\n";
         }
         $segCount = $mysql->geSgmsCount($id);
         $dpl = new DashPlaylist($dashfile);
         $dpl->generateMPD($duration, 0, $segCount);
         $dpl->generateM3U8($segCount);
         $mysql->close();
     } else {
         if (!$dashfile->isValid()) {
             return "ERROR: File is invalid!\n";
         }
         if ($dashfile->saveFile()) {
             if (!$mysql->connect()) {
                 return "ERROR: Sql server connect error!\n";
             }
             if ($sn == 0) {
                 $mysql->insertNewVideo($id, $sn, $id, $duration);
             } else {
                 $mysql->updateNumSegs($id, $sn);
             }
             $mysql->close();
         } else {
             return "ERROR: File save error!\n";
         }
         if ($convert->doConvert()) {
             if (!$mysql->connect()) {
                 return "ERROR: Sql server connect error!\n";
             }
             if (!$mysql->updateNumConverted($id, $sn)) {
                 return "ERROR: Sql UPDATE error\n";
             }
             $mysql->close();
         }
         $start = $sn - 1;
         //if ($sn >= 3) {
         //    $start = $sn - 2;
         //}
         $dpl = new DashPlaylist($dashfile);
         $dpl->generateMPD($duration, $start, $sn);
     }
     return "SUCCESS";
 }
开发者ID:xueerk,项目名称:Moblie-MPEG-DASH-Player,代码行数:56,代码来源:ServerController.class.php

示例4: curl_func

 public function curl_func()
 {
     $data = $_POST;
     //Set destination URL
     $url = "http://localhost/SwipeContest/index.php/Welcome";
     $tst = new Convert();
     $result = $tst->cURLSnippet($url, $data);
     print_r($result);
     echo "POST data forwarded via cURL to " . $url;
 }
开发者ID:kulgee001,项目名称:SwipeContest,代码行数:10,代码来源:Test.php

示例5: formatValue

 protected function formatValue($record, $source, $info)
 {
     // Field sources
     //if(is_string($source)) {
     $val = Convert::raw2xml($record->{$source});
     //} else {
     //	$val = $record->val($source[0], $source[1]);
     //}
     // Casting, a la TableListField.  We're deep-calling a helper method on TableListField that
     // should probably be pushed elsewhere...
     if (!empty($info['casting'])) {
         $val = TableListField::getCastedValue($val, $info['casting']);
     }
     // Formatting, a la TableListField
     if (!empty($info['formatting'])) {
         $format = str_replace('$value', "__VAL__", $info['formatting']);
         $format = preg_replace('/\\$([A-Za-z0-9-_]+)/', '$record->$1', $format);
         $format = str_replace('__VAL__', '$val', $format);
         $val = eval('return "' . $format . '";');
     }
     $prefix = empty($info['newline']) ? "" : "<br>";
     $classClause = "";
     if (isset($info['title'])) {
         $cssClass = preg_replace('/[^A-Za-z0-9]+/', '', $info['title']);
         $classClause = "class=\"{$cssClass}\"";
     }
     if (isset($info['link']) && $info['link']) {
         $link = $info['link'] === true && $record->hasMethod('CMSEditLink') ? $record->CMSEditLink() : $info['link'];
         return $prefix . "<a {$classClause} href=\"{$link}\">{$val}</a>";
     } else {
         return $prefix . "<span {$classClause}>{$val}</span>";
     }
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:33,代码来源:SideReport.php

示例6: load

 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $response->setBody(Convert::array2json(call_user_func($this->source, $request->getVar('val'))));
     return $response;
 }
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:7,代码来源:BootstrapTypeaheadField.php

示例7: Field

    public function Field($properties = array())
    {
        $content = '';
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
        Requirements::javascript(FRAMEWORK_DIR . "/javascript/ToggleField.js");
        if ($this->startClosed) {
            $this->addExtraClass('startClosed');
        }
        $valforInput = $this->value ? Convert::raw2att($this->value) : "";
        $rawInput = Convert::html2raw($valforInput);
        if ($this->charNum) {
            $reducedVal = substr($rawInput, 0, $this->charNum);
        } else {
            $reducedVal = DBField::create_field('Text', $rawInput)->{$this->truncateMethod}();
        }
        // only create togglefield if the truncated content is shorter
        if (strlen($reducedVal) < strlen($rawInput)) {
            $content = <<<HTML
\t\t\t<div class="readonly typography contentLess" style="display: none">
\t\t\t\t{$reducedVal}
\t\t\t\t&nbsp;<a href="#" class="triggerMore">{$this->labelMore}</a>
\t\t\t</div>
\t\t\t<div class="readonly typography contentMore">
\t\t\t\t{$this->value}
\t\t\t\t&nbsp;<a href="#" class="triggerLess">{$this->labelLess}</a>
\t\t\t</div>\t
\t\t\t<br />
\t\t\t<input type="hidden" name="{$this->name}" value="{$valforInput}" />
HTML;
        } else {
            $this->dontEscape = true;
            $content = parent::Field();
        }
        return $content;
    }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:35,代码来源:ToggleField.php

示例8: Field

 function Field()
 {
     $XML_title = $this->allowHTML ? $this->title : Convert::raw2xml($this->title);
     // extraclass
     $XML_class = $this->extraClass() ? " class=\"{$this->extraClass()}\"" : '';
     return "<h{$this->headingLevel}{$XML_class}>{$XML_title}</h{$this->headingLevel}>";
 }
开发者ID:ramziammar,项目名称:websites,代码行数:7,代码来源:HeaderField.php

示例9: notifySubscribers

 /**
  * Send email to subscribers, notifying them the thread has been created or post added.
  */
 public function notifySubscribers()
 {
     // all members id except current user
     $member_id = Member::currentUserID();
     $list = DataObject::get("Forum_Subscribers", "\"ForumID\" = '" . $this->owner->ForumID . "' AND \"MemberID\" != '{$member_id}'");
     if ($list) {
         foreach ($list as $obj) {
             $SQL_id = Convert::raw2sql((int) $obj->MemberID);
             // Get the members details
             $member = DataObject::get_one("Member", "\"Member\".\"ID\" = '{$SQL_id}'");
             if ($member) {
                 //error_log("email sent ".$member->Email);
                 $type = $obj->Type;
                 switch ($type) {
                     // send all email notification
                     case 'all':
                         $this->createEmail($member);
                         break;
                         // send new thread only email notification
                     // send new thread only email notification
                     case 'thread':
                         //if($this->owner->isFirstPost()){
                         $this->createEmail($member);
                         //}
                         break;
                         //
                     //
                     default:
                         break;
                 }
             }
         }
     }
 }
开发者ID:liquidedge,项目名称:forum_subscribe,代码行数:37,代码来源:ForumPostEmailSubscribers.php

示例10: requireDefaultRecords

 /**
  *	The process to automatically construct data object output configurations, executed on project build.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Grab the list of data objects that have been completely removed.
     foreach (DB::getConn()->tableList() as $table) {
         // Delete existing output configurations for these data objects.
         if (!class_exists($table)) {
             $existing = DataObjectOutputConfiguration::get_one('DataObjectOutputConfiguration', "IsFor = '" . Convert::raw2sql($table) . "'");
             $this->deleteConfiguration($table, $existing);
         }
     }
     // Grab the list of all data object types, along with any inclusions/exclusions defined.
     $objects = ClassInfo::subclassesFor('DataObject');
     $inclusions = self::$custom_inclusions;
     $exclusions = array_unique(array_merge(self::$exclusions, self::$custom_exclusions));
     // Check existing output configurations for these data objects.
     foreach ($objects as $object) {
         $existing = DataObjectOutputConfiguration::get_one('DataObjectOutputConfiguration', "IsFor = '" . Convert::raw2sql($object) . "'");
         // Delete existing output configurations for invalid data objects, or for those excluded.
         if ($existing && (self::$disabled || get_parent_class($object) !== 'DataObject' || ClassInfo::classImplements($object, 'TestOnly') || count($inclusions) > 0 && !in_array($object, $inclusions) || count($inclusions) === 0 && in_array($object, $exclusions))) {
             $this->deleteConfiguration($object, $existing);
         } else {
             if (!$existing && !self::$disabled && get_parent_class($object) === 'DataObject' && !ClassInfo::classImplements($object, 'TestOnly') && (count($inclusions) > 0 && in_array($object, $inclusions) || count($inclusions) === 0 && !in_array($object, $exclusions))) {
                 $this->addConfiguration($object);
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:31,代码来源:DataObjectOutputConfiguration.php

示例11: addtocart

 /**
  * Handles form submission
  * @param array $data
  * @return bool|\SS_HTTPResponse
  */
 public function addtocart(array $data)
 {
     $groupedProduct = $this->getController()->data();
     if (empty($data) || empty($data['Product']) || !is_array($data['Product'])) {
         $this->sessionMessage(_t('GroupedCartForm.EMPTY', 'Please select at least one product.'), 'bad');
         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
         return $response ? $response : $this->controller->redirectBack();
     }
     $cart = ShoppingCart::singleton();
     foreach ($data['Product'] as $id => $prodReq) {
         if (!empty($prodReq['Quantity']) && $prodReq['Quantity'] > 0) {
             $prod = Product::get()->byID($id);
             if ($prod && $prod->exists()) {
                 $saveabledata = !empty($this->saveablefields) ? Convert::raw2sql(array_intersect_key($data, array_combine($this->saveablefields, $this->saveablefields))) : $prodReq;
                 $buyable = $prod;
                 if (isset($prodReq['Attributes'])) {
                     $buyable = $prod->getVariationByAttributes($prodReq['Attributes']);
                     if (!$buyable || !$buyable->exists()) {
                         $this->sessionMessage("{$prod->InternalItemID} is not available with the selected options.", "bad");
                         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
                         return $response ? $response : $this->controller->redirectBack();
                     }
                 }
                 if (!$cart->add($buyable, (int) $prodReq['Quantity'], $saveabledata)) {
                     $this->sessionMessage($cart->getMessage(), $cart->getMessageType());
                     $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
                     return $response ? $response : $this->controller->redirectBack();
                 }
             }
         }
     }
     $this->extend('updateGroupCartResponse', $this->request, $response, $groupedProduct, $data, $this);
     return $response ? $response : ShoppingCart_Controller::direct($cart->getMessageType());
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-groupedproducts,代码行数:39,代码来源:GroupedCartForm.php

示例12: perform

 public function perform()
 {
     set_time_limit(0);
     $log = new DeploynautLogFile($this->args['logfile']);
     $projects = DNProject::get()->filter('Name', Convert::raw2sql($this->args['projectName']));
     $project = $projects->first();
     $path = $project->getLocalCVSPath();
     $env = $this->args['env'];
     $log->write('Starting git fetch for project "' . $project->Name . '"');
     // if an alternate user has been configured for clone, run the command as that user
     // @todo Gitonomy doesn't seem to have any way to prefix the command properly, if you
     // set 'sudo -u composer git' as the "command" parameter, it tries to run the whole
     // thing as a single command and fails
     $user = DNData::inst()->getGitUser();
     if (!empty($user)) {
         $command = sprintf('cd %s && sudo -u %s git fetch -p origin +refs/heads/*:refs/heads/* --tags', $path, $user);
         $process = new \Symfony\Component\Process\Process($command);
         $process->setEnv($env);
         $process->setTimeout(3600);
         $process->run();
         if (!$process->isSuccessful()) {
             throw new RuntimeException($process->getErrorOutput());
         }
     } else {
         $repository = new Gitonomy\Git\Repository($path, array('environment_variables' => $env));
         $repository->run('fetch', array('-p', 'origin', '+refs/heads/*:refs/heads/*', '--tags'));
     }
     $log->write('Git fetch is finished');
 }
开发者ID:antons-,项目名称:deploynaut,代码行数:29,代码来源:FetchJob.php

示例13: dosave

 /**
  * Form action handler for ContactInquiryForm.
  *
  * @param array $data The form request data submitted
  * @param Form $form The {@link Form} this was submitted on
  */
 function dosave(array $data, Form $form, SS_HTTPRequest $request)
 {
     $SQLData = Convert::raw2sql($data);
     $attrs = $form->getAttributes();
     if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
         // most probably spam - terminate silently
         Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
         return;
     }
     $item = new ContactInquiry();
     $form->saveInto($item);
     // $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
     $item->write();
     $mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
     $mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
     $mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
     $email = new Email($mailFrom, $mailTo, $mailSubject);
     $email->replyTo($SQLData['Email']);
     $email->setTemplate("ContactInquiry");
     $email->populateTemplate($SQLData);
     $email->send();
     // $this->controller->redirectBack();
     if ($email->send()) {
         $this->controller->redirect($this->controller->Link() . "success");
     } else {
         $this->controller->redirect($this->controller->Link() . "error");
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:jelicanin-silverstripe-contact-page,代码行数:35,代码来源:ContactInquiryForm.php

示例14: load

 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $response->setBody(Convert::array2json(array("_memberID" => Member::currentUserID())));
     return $response;
 }
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:7,代码来源:KeepAliveField.php

示例15: MetaTags

 /**
  * Return the title, description, keywords and language metatags.
  * 
  * @todo Move <title> tag in separate getter for easier customization and more obvious usage
  * 
  * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
  * @return string The XHTML metatags
  */
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->Title) . "</title>\n";
     }
     $generator = trim(Config::inst()->get('SiteTree', 'meta_generator'));
     if (!empty($generator)) {
         $tags .= "<meta name=\"generator\" content=\"" . Convert::raw2att($generator) . "\" />\n";
     }
     $charset = Config::inst()->get('ContentNegotiator', 'encoding');
     $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset={$charset}\" />\n";
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     if ($this->ExtraMeta) {
         $tags .= $this->ExtraMeta . "\n";
     }
     if (Permission::check('CMS_ACCESS_CMSMain') && in_array('CMSPreviewable', class_implements($this)) && !$this instanceof ErrorPage) {
         $tags .= "<meta name=\"x-page-id\" content=\"{$this->ID}\" />\n";
         $tags .= "<meta name=\"x-cms-edit-link\" content=\"" . $this->CMSEditLink() . "\" />\n";
     }
     $this->extend('MetaTags', $tags);
     return $tags;
 }
开发者ID:i-lateral,项目名称:silverstripe-catalogue,代码行数:33,代码来源:CatalogueController.php


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