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


PHP StringUtils::strToBool方法代码示例

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


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

示例1: showThumbnails

 public function showThumbnails()
 {
     $json = $this->getParameter('value');
     if (empty($json)) {
         return '';
     }
     $json = JSONUtils::decode($json);
     $thumbs = $this->getParameter('thumbnails');
     $tlist = array();
     if (!empty($thumbs)) {
         $tlist = explode(',', $thumbs);
     }
     $xmod = StringUtils::strToBool($this->getParameter('xmod'));
     $markup = '';
     if ($xmod) {
         foreach ($json as $thumb) {
             if (!empty($list) && in_array($thumb->value, $tlist) || empty($tlist)) {
                 $markup .= '<image id="' . $thumb->url . '" width="full"/>';
             }
         }
     } else {
         $markup .= '<ul class="thumbnail-list">';
         foreach ($json as $thumb) {
             if (!empty($tlist) && in_array($thumb->value, $tlist) || empty($tlist)) {
                 $markup .= '<li><p><img src="' . $thumb->url . '" alt="' . $this->getLocal('Title') . '" /></p><p><strong>Size:</strong> ' . $thumb->value . '</p></li>';
             }
         }
         $markup .= '</ul>';
     }
     return $markup;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion-advanced-media,代码行数:31,代码来源:MediaFilterer.php

示例2: items

 public function items()
 {
     $feedURL = (string) $this->getRequiredTemplateVariable('FeedURL');
     $nativeOrder = StringUtils::strToBool((string) $this->getTemplateVariable('NativeOrder'));
     $includeImage = StringUtils::strToBool((string) $this->getTemplateVariable('IncludeImage'));
     $maxRows = intval((string) $this->getRequiredTemplateVariable('MaxRows'));
     $items = array();
     if (!URLUtils::isUrl($feedURL)) {
         return $items;
     }
     try {
         $feed = $this->FeedParser->parseFeed($feedURL, $nativeOrder);
         $i = 0;
         foreach ($feed->get_items() as $item) {
             if ($i >= $maxRows) {
                 break;
             }
             if (trim($item->get_title()) == '') {
                 continue;
             }
             $itemDate = null;
             if ($item->get_date() != '') {
                 $itemDate = $this->DateFactory->newStorageDate($item->get_date());
             }
             $img = null;
             if ($includeImage) {
                 // first try to get it from the enclosure node itself
                 $tags = $item->get_item_tags('', 'enclosure');
                 if (is_array($tags)) {
                     foreach ($tags as $tag) {
                         if (!isset($tag['attribs']['']['type'])) {
                             continue;
                         }
                         if (strpos($tag['attribs']['']['type'], 'image') !== false) {
                             $img = isset($tag['attribs']['']['url']) ? $tag['attribs']['']['url'] : null;
                             break;
                         }
                     }
                 }
                 if (empty($img)) {
                     $enclosure = $item->get_enclosure();
                     if ($enclosure) {
                         $img = $enclosure->get_thumbnail();
                         if (empty($img)) {
                             $img = $enclosure->get_link();
                         }
                     }
                 }
             }
             $items[] = array('Permalink' => $item->get_permalink(), 'Title' => $item->get_title(), 'Description' => $item->get_description(), 'PublishDate' => $itemDate, 'Image' => $img);
             $i++;
         }
     } catch (FeedParserException $fpe) {
         $this->Logger->debug($fpe->getMessage());
     }
     return $items;
 }
开发者ID:wb-crowdfusion,项目名称:wb-lib,代码行数:57,代码来源:WbfetchWebController.php

示例3: isDeprecated

 public function isDeprecated()
 {
     $name = (string) $this->getRequiredParameter('name');
     if (!$this->nameExists()) {
         return true;
     }
     $image = $this->_imageNames[$name];
     if (array_key_exists('Deprecated', $image)) {
         return StringUtils::strToBool($image['Deprecated']);
     }
     return false;
 }
开发者ID:wb-crowdfusion,项目名称:wb-lib,代码行数:12,代码来源:WbimageFilterer.php

示例4: findAll

 public function findAll(DTO $dto)
 {
     $sd = __CLASS__ . (string) serialize($dto);
     $slugs = $this->SystemCache->get($sd);
     if ($slugs === false) {
         $this->loadSource();
         $slugs = array();
         $sort_array = array();
         $dir = 'ASC';
         $orderbys = $dto->getOrderBys();
         if (!empty($orderbys)) {
             foreach ($orderbys as $col => $dir) {
             }
         } else {
             $col = 'Slug';
         }
         foreach ($this->objectsBySlug as $slug => $obj) {
             if ($dto->hasParameter('Enabled') && $obj->Enabled != $dto->getParameter('Enabled')) {
                 continue;
             }
             if (!$dto->hasParameter('FlattenChildren') || StringUtils::strToBool($dto->getParameter('FlattenChildren')) == false) {
                 if ($obj->hasParentSlug()) {
                     continue;
                 }
             }
             if (($val = $dto->getParameter('Slug')) != null) {
                 if ($obj->Slug != $val) {
                     continue;
                 }
             }
             if (($val = $dto->getParameter('PluginID')) != null) {
                 if ($obj->PluginID != $val) {
                     continue;
                 }
             }
             $slugs[] = $slug;
             $sort_array[] = $obj[$col];
         }
         array_multisort($sort_array, strtolower($dir) == 'asc' ? SORT_ASC : SORT_DESC, SORT_REGULAR, $slugs);
         $this->SystemCache->put($sd, $slugs, 0);
     }
     // retrieve objects
     $rows = $this->multiGetBySlug($slugs);
     $results = array();
     foreach ($slugs as $slug) {
         if (isset($rows[$slug])) {
             $results[] = $rows[$slug];
         }
     }
     return $dto->setResults($results);
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:51,代码来源:CMSNavItemDAO.php

示例5: applyFilter

 /**
  * Rotates an image by specified degrees.
  *
  * Options:
  * degrees => value between -180 and +180 (default is 90)
  * autoCrop => if true, image is auto-cropped to remove empty corners (only valid in 'rotate' mode - default scale = 1.3)
  * backgroundColor => color to fill empty corners with e.g. 'blue' or 'rgb(255,255,255)' or '#FFFFFF'(default)
  * mode => 'rotate'(default) or 'distort' - if 'distort' empty corners are blurred rather than filled with background color
  * scale => for distort mode scales image to reduce empty corners - useful values are between about 1.1 to 1.5
  *
  * @param $sourceFile The source file to operate on
  * @param $options An array of otions as described above
  *
  * @see AbstractImageFilter::applyFilter()
  */
 public function applyFilter($sourceFile, $options = null)
 {
     if (!empty($options['angle']) && !is_numeric($options['angle'])) {
         throw new ImageFilterException("Degrees parameter must be a valid integer value");
     }
     $this->degrees = sprintf("%+d", !empty($options['angle']) ? intval($options['angle']) : 0);
     if ($this->degrees < -180 || $this->degrees > 180) {
         throw new ImageFilterException("Degrees parameter must be between -180 and +180");
     }
     $this->autoCrop = StringUtils::strToBool($options['autoCrop']);
     $this->mode = !empty($options['mode']) ? $options['mode'] : 'rotate';
     $this->scale = !empty($options['scale']) ? $options['scale'] : '0';
     // default to white if no background color specified
     $this->backgroundColor = !empty($options['backgroundColor']) ? $options['backgroundColor'] : '#ffffff';
     return parent::applyFilter($sourceFile, $options);
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion-advanced-media,代码行数:31,代码来源:AbstractRotateFilter.php

示例6: rebuildThumbnails

 /**
  * Rebuilds thumbnails for a single node ref or array of node refs.
  */
 public function rebuildThumbnails()
 {
     $data = $this->getData();
     $forceRebuildExisting = isset($data['forceRebuildExisting']) ? StringUtils::strToBool($data['forceRebuildExisting']) : false;
     if (isset($data['nodeRef'])) {
         $this->rebuildThumbnailsOnNodeRef($data['nodeRef'], $forceRebuildExisting);
         return;
     }
     if (!isset($data['nodeRefs']) || !is_array($data['nodeRefs'])) {
         return;
     }
     foreach ($data['nodeRefs'] as $nodeRef) {
         $this->rebuildThumbnailsOnNodeRef($nodeRef, $forceRebuildExisting);
         $this->TransactionManager->commit()->begin();
         usleep(100000);
     }
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion-advanced-media,代码行数:20,代码来源:ImagesWorker.php

示例7: filter

 protected function filter()
 {
     $eventName = $this->getParameter('name');
     if (StringUtils::strToBool($this->getParameter('allowTemplateCode')) == true) {
         $this->allowTemplateCode();
     }
     $params = $this->getParameters();
     $output = new Transport();
     foreach ($params as $k => $v) {
         $output->{$k} = $v;
     }
     if (!isset($output->Node)) {
         $output->Node = $this->getLocal('Node');
     }
     $this->Events->trigger($eventName, $output);
     return $output->value;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:17,代码来源:EventFilterer.php

示例8: getDuration

 public function getDuration()
 {
     $name = trim((string) $this->getParameter('name'));
     $fullPage = StringUtils::strToBool((string) $this->getParameter('FullPage'));
     if (empty($name)) {
         $name = 'default';
     }
     if (in_array($name, explode(',', 'none,never,off,0,zero,no'))) {
         return 0;
     }
     if (!array_key_exists($name, $this->durations)) {
         $name = 'default';
     }
     $duration = abs((int) $this->durations[$name]);
     if (!$fullPage || $duration < 1) {
         return $duration;
     }
     // full page cache duration should be half the cache time
     return ceil($duration / 2);
 }
开发者ID:wb-crowdfusion,项目名称:wb-lib,代码行数:20,代码来源:WbcacheFilterer.php

示例9: handle

 protected function handle()
 {
     $qsa = StringUtils::strToBool((string) $this->getTemplateVariable('QSA'));
     $destination = $this->getRequiredTemplateVariable('Destination');
     $isPermanent = StringUtils::strToBool((string) $this->getTemplateVariable('IsPermanent'));
     $sc = $isPermanent ? Response::SC_MOVED_PERMANENTLY : Response::SC_OK;
     if ($qsa) {
         $qs = $this->Request->getQueryString();
         if (!empty($qs)) {
             if (strpos($destination, '?') === false) {
                 $destination .= '?' . $qs;
             } else {
                 $destination .= '&' . $qs;
             }
         }
     }
     $this->Response->addHeader('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0');
     $this->Response->addHeader('Expires', $this->DateFactory->newLocalDate()->toRFCDate());
     $this->Response->sendStatus($sc)->sendRedirect($destination);
 }
开发者ID:wb-crowdfusion,项目名称:wb-lib,代码行数:20,代码来源:WbqsredirectWebController.php

示例10: applyFilter

 /**
  * Creates an underlay of color or an image to the source image.
  *
  * image => a base64 encoded data string to use as background matte
  * repeat => if the image should be repeated
  * color => a color to use if an image is not set
  * width => the width of the canvas to place the source image on
  * height => the height of the canvas to place the source image on
  * anchor => may be one of 'northwest', 'north', 'northeast', 'west', 'center', 'east', 'southwest', 'south' or 'southeast'
  * offsetX => the X offset from relative to the anchor position (default is 0)
  * offsetY => the Y offset from relative to the anchor position (default is 0)
  *
  * @param $sourceFile The source file to operate on
  * @param $options An array of options as described above
  *
  * @see AbstractImageFilter::applyFilter()
  */
 public function applyFilter($sourceFile, $options = null)
 {
     if (!empty($options['image']) && $options['image'] != 'null') {
         $this->image = $this->prepareImageData($options['image']);
         $this->repeat = StringUtils::strToBool($options['repeat']);
     }
     $this->color = !empty($options['color']) ? '#' . preg_replace('/[^a-f0-9]/i', '', $options['color']) : "#ffffff";
     if (!empty($this->color) && !preg_match('/^#[a-f0-9]{6}$/i', $this->color)) {
         throw new ImageFilterException("Color must be a valid hex value " . $this->color);
     }
     if (!empty($options['width']) && !is_numeric($options['width'])) {
         throw new ImageFilterException("Canvas width must be a valid integer value");
     }
     $this->width = !empty($options['width']) ? intval($options['width']) : 0;
     if (!empty($options['height']) && !is_numeric($options['height'])) {
         throw new ImageFilterException("Canvas height must be a valid integer value");
     }
     $this->height = !empty($options['height']) ? intval($options['height']) : 0;
     $this->populateAnchorFields($options);
     return parent::applyFilter($sourceFile, $options);
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion-advanced-media,代码行数:38,代码来源:AbstractMatteFilter.php

示例11: primaryImageEmbedOptions

 protected function primaryImageEmbedOptions()
 {
     if (!count($this->_primaryImageEmbedOptions)) {
         foreach ($this->_imageNames as $key => $image) {
             if (array_key_exists('Title', $image)) {
                 $title = $image['Title'];
             } else {
                 $title = SlugUtils::unsluggify($key);
             }
             $deprecated = false;
             if (array_key_exists('Deprecated', $image)) {
                 $deprecated = StringUtils::strToBool($image['Deprecated']);
             }
             $size = '';
             if (array_key_exists('Size', $image)) {
                 $size = (string) $image['Size'];
             }
             $this->_primaryImageEmbedOptions[] = array('EmbedOptionSlug' => $key, 'EmbedOptionTitle' => $title, 'EmbedOptionDeprecated' => $deprecated, 'EmbedOptionSize' => $size);
         }
         $this->_primaryImageEmbedOptions[] = array('EmbedOptionSlug' => 'off', 'EmbedOptionTitle' => 'DO NOT Auto Embed', 'EmbedOptionDeprecated' => false, 'EmbedOptionSize' => '');
     }
     return $this->_primaryImageEmbedOptions;
 }
开发者ID:wb-crowdfusion,项目名称:wb-lib,代码行数:23,代码来源:WblibCmsController.php

示例12: findAll

 public function findAll()
 {
     $dto = new NodeQuery();
     $this->buildLimitOffset($dto);
     $this->buildSorts($dto);
     $this->buildFilters($dto);
     $this->passthruParameter($dto, 'Elements.in');
     $this->passthruParameter($dto, 'Sites.in');
     //$this->passthruParameter($dto, 'SiteIDs.in');
     $this->passthruParameter($dto, 'Slugs.in');
     $this->passthruParameter($dto, 'Meta.select');
     $this->passthruParameter($dto, 'OutTags.select');
     $this->passthruParameter($dto, 'InTags.select');
     $this->passthruParameter($dto, 'Sections.select');
     $this->passthruParameter($dto, 'OrderByInTag');
     $this->passthruParameter($dto, 'OrderByOutTag');
     $this->passthruParameter($dto, 'Title.like');
     $this->passthruParameter($dto, 'Title.ieq');
     $this->passthruParameter($dto, 'Title.eq');
     $this->passthruParameter($dto, 'Title.firstChar');
     $this->passthruParameter($dto, 'Status.isActive');
     $this->passthruParameter($dto, 'Status.all');
     $this->passthruParameter($dto, 'Status.eq');
     $this->passthruParameter($dto, 'TreeID.childOf');
     $this->passthruParameter($dto, 'TreeID.eq');
     $this->passthruParameter($dto, 'ActiveDate.before');
     $this->passthruParameter($dto, 'ActiveDate.after');
     $this->passthruParameter($dto, 'ActiveDate.start');
     $this->passthruParameter($dto, 'ActiveDate.end');
     $this->passthruParameter($dto, 'CreationDate.before');
     $this->passthruParameter($dto, 'CreationDate.after');
     $this->passthruParameter($dto, 'CreationDate.start');
     $this->passthruParameter($dto, 'CreationDate.end');
     $this->passthruParameter($dto, 'OutTags.exist');
     $this->passthruParameter($dto, 'InTags.exist');
     $this->passthruParameter($dto, 'Meta.exist');
     $this->passthruParameter($dto, 'Sections.exist');
     foreach ($this->Request->getParameters() as $name => $value) {
         if (strpos($name, '#') === 0) {
             $dto->setParameter(str_replace('_', '.', $name), $value);
         }
     }
     $dto->isRetrieveTotalRecords(true);
     if ($this->Request->getParameter('OrderBy') != null) {
         $dto->setOrderBys(array());
         $dto->setOrderBy($this->Request->getParameter('OrderBy'));
     }
     $this->Events->trigger('NodeApiController.findAll', $dto);
     $dto = $this->RegulatedNodeService->findAll($dto, $this->Request->getParameter('ForceReadWrite') != null ? StringUtils::strToBool($this->Request->getParameter('ForceReadWrite')) : false);
     echo $this->readDTO($dto);
     return null;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:52,代码来源:NodeApiController.php

示例13: loadTemplateExtended

 /**
  * @see TemplateEngineInterface::loadTemplateExtended
  */
 public function loadTemplateExtended(Template $template, &$globals)
 {
     $params = $template->getLocals();
     if (!empty($params['Presenter'])) {
         $template->setPresenter($params['Presenter']);
     }
     if (!empty($params['CacheTime'])) {
         $template->setCacheTime((int) $params['CacheTime']);
     } else {
         $template->setCacheTime(300);
     }
     if ($template->getCacheTime() > 0 && (empty($params['NoCache']) || StringUtils::strToBool($params['NoCache']) == false)) {
         $template->setCacheable(true);
     }
     return $template;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:19,代码来源:PresenterTemplateEngine.php

示例14: setAudiencescienceEnabled

 public function setAudiencescienceEnabled()
 {
     $this->audiencescienceEnabled = StringUtils::strToBool((string) $this->getRequiredParameter('value'));
 }
开发者ID:wb-crowdfusion,项目名称:wb-ads,代码行数:4,代码来源:WbadsFilterer.php

示例15: filterNode


//.........这里部分代码省略.........
                         return false;
                     }
                     break;
                 case 'CreationDate.end':
                     if ($node['CreationDate']->toUnix() >= $value->toUnix()) {
                         return false;
                     }
                     break;
                 case 'Status.eq':
                     switch (strtolower($value)) {
                         case 'published':
                             if (strtolower($node['Status']) != 'published') {
                                 return false;
                             }
                             break;
                         case 'draft':
                             if (strtolower($node['Status']) != 'draft') {
                                 return false;
                             }
                             break;
                         case 'deleted':
                             if (strtolower($node['Status']) != 'deleted') {
                                 return false;
                             }
                             break;
                         default:
                             if (strtolower($node['Status']) == 'deleted') {
                                 return false;
                             }
                             break;
                     }
                     break;
                 case 'Status.isActive':
                     if (StringUtils::strToBool($value) == true && (strcmp('published', $node['Status']) !== 0 || $node['ActiveDate']->toUnix() >= $this->now->toUnix())) {
                         return false;
                     }
                     break;
                 case 'Status.all':
                     if (StringUtils::strToBool($value) == false && strcmp('deleted', $node['Status']) === 0) {
                         return false;
                     }
                     break;
                     //                case 'IncludesMeta':
                     //                    $found = false;
                     //                    foreach($value as $partial) {
                     //                        $meta = MetaUtils::filterMeta($node['Metas'],$partial->getMetaName());
                     //                        if($partial->match($meta))
                     //                            $found = true;
                     //                    }
                     //                    if(!$found)
                     //                        return false;
                     //                    break;
                 //                case 'IncludesMeta':
                 //                    $found = false;
                 //                    foreach($value as $partial) {
                 //                        $meta = MetaUtils::filterMeta($node['Metas'],$partial->getMetaName());
                 //                        if($partial->match($meta))
                 //                            $found = true;
                 //                    }
                 //                    if(!$found)
                 //                        return false;
                 //                    break;
                 case 'Meta.exist':
                     foreach ($value as $partial) {
                         $meta = $node->getMeta($partial->getMetaName());
                         if (empty($meta) || !$partial->match($meta)) {
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:67,代码来源:NodesHelper.php


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