本文整理汇总了PHP中dmString类的典型用法代码示例。如果您正苦于以下问题:PHP dmString类的具体用法?PHP dmString怎么用?PHP dmString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dmString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: executeRate
public function executeRate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('POST'));
list($class, $id) = dmString::decode($request->getParameter('hash'));
$this->forward404Unless($table = dmDb::table($class));
$this->forward404Unless($record = $table->find($id));
$this->forward404Unless($table->hasTemplate('DmRatable'));
$template = $table->getTemplate('DmRatable');
$options = $template->getOptions();
$value = (int) $request->getParameter('value');
$this->forward404Unless($value >= 0 && $value <= $options['max_rate']);
$rate = array('rate' => $value);
if ($options['user']) {
$this->forward404Unless($this->getUser()->isAuthenticated());
$rate['dm_user_id'] = $this->getUser()->getUserId();
} else {
$rate['session_id'] = session_id();
}
if ($value) {
$record->addRate($rate);
$message = $this->getService('i18n')->__('Rating saved (%rate%)', array('%rate%' => $value));
} else {
$record->cancelRate($rate);
$message = $this->getService('i18n')->__('Rating removed');
}
return $this->renderComponent('dmRatable', 'rating', array('record' => $record, 'message' => $message));
}
开发者ID:KnpLabs,项目名称:dmRatablePlugin,代码行数:27,代码来源:actions.class.php
示例2: withDmMedia
/**
* Join media for this columnName or alias
* return @dmDoctrineQuery $this
*/
public function withDmMedia($alias, $rootAlias = null)
{
$rootAlias = $rootAlias ? $rootAlias : $this->getRootAlias();
$mediaJoinAlias = $rootAlias . dmString::camelize($alias);
$folderJoinAlias = $mediaJoinAlias . 'Folder';
return $this->leftJoin(sprintf('%s.%s %s, %s.%s %s', $rootAlias, $alias, $mediaJoinAlias, $mediaJoinAlias, 'Folder', $folderJoinAlias));
}
开发者ID:theolymp,项目名称:diem,代码行数:11,代码来源:dmDoctrineQuery.php
示例3: filterViewVars
protected function filterViewVars(array $vars = array())
{
$vars = parent::filterViewVars($vars);
$menuClass = dmArray::get($vars, 'menuClass');
$vars['menu'] = $this->getService('menu', $menuClass ? $menuClass : null)
->ulClass($vars['ulClass']);
foreach($vars['items'] as $index => $item)
{
$menuItem = $vars['menu']
->addChild($index.'-'.dmString::slugify($item['text']), $item['link'])
->label($item['text'])
->secure(!empty($item['secure']))
->liClass($vars['liClass'])
->addRecursiveChildren(dmArray::get($item, 'depth', 0));
if(!empty($item['nofollow']) && $menuItem->getLink())
{
$menuItem->getLink()->set('rel', 'nofollow');
}
}
unset($vars['items'], $vars['ulClass'], $vars['liClass']);
return $vars;
}
开发者ID:Regmaya,项目名称:diem,代码行数:28,代码来源:dmWidgetNavigationMenuView.php
示例4: addWidget
public function addWidget(DmZone $zone, $moduleAction)
{
list($module, $action) = explode('/', $moduleAction);
$this->info('Add a ' . $moduleAction . ' widget')->get(sprintf('/index.php/+/dmWidget/add?to_dm_zone=%d&mod=' . $module . '&act=' . $action . '&dm_cpi=%d', $zone->id, $this->getPage()->id))->checks(array('module_action' => 'dmWidget/add', 'method' => 'get'))->has('.dm_widget.' . str_replace('dm_widget_', '', dmString::underscore($module)) . '.' . dmString::underscore($action));
$zone->refreshRelated('Widgets');
return $this;
}
开发者ID:jdart,项目名称:diem,代码行数:7,代码来源:dmFrontTestFunctional.php
示例5: renderText
protected function renderText()
{
if (isset($this->options['text'])) {
return $this->options['text'];
}
return dmString::escape($this->page->_getI18n('name'));
}
开发者ID:jdart,项目名称:diem,代码行数:7,代码来源:dmFrontLinkTagPage.php
示例6: getWidgetTypes
public function getWidgetTypes()
{
if (null === $this->widgetTypes) {
$cache = $this->serviceContainer->getService('cache_manager')->getCache('dm/widget/' . sfConfig::get('sf_app') . sfConfig::get('sf_environment'));
$this->widgetTypes = $cache->get('types');
if (empty($this->widgetTypes)) {
$internalConfigFile = $this->serviceContainer->getService('config_cache')->checkConfig($this->getOption('config_file'));
$internalConfig = (include $internalConfigFile);
$this->widgetTypes = array();
$controller = $this->serviceContainer->getService('controller');
foreach ($internalConfig as $moduleKey => $actions) {
$this->widgetTypes[$moduleKey] = array();
foreach ($actions as $actionKey => $action) {
$fullKey = $moduleKey . dmString::camelize($actionKey);
$name = dmArray::get($action, 'name', dmString::humanize($actionKey));
$widgetTypeConfig = array('full_key' => $moduleKey . ucfirst($actionKey), 'name' => $name, 'public_name' => dmArray::get($action, 'public_name', dmString::humanize($name)), 'form_class' => dmArray::get($action, 'form_class', $fullKey . 'Form'), 'view_class' => dmArray::get($action, 'view_class', $fullKey . 'View'), 'use_component' => $this->componentExists($moduleKey, $fullKey), 'cache' => dmArray::get($action, 'cache', false));
$this->widgetTypes[$moduleKey][$actionKey] = new dmWidgetType($moduleKey, $actionKey, $widgetTypeConfig);
}
}
foreach ($this->serviceContainer->getService('module_manager')->getProjectModules() as $moduleKey => $module) {
$this->widgetTypes[$moduleKey] = array();
foreach ($module->getComponents() as $componentKey => $component) {
$baseClass = 'dmWidget' . dmString::camelize($component->getType());
$widgetTypeConfig = array('full_key' => $moduleKey . ucfirst($componentKey), 'name' => $component->getName(), 'public_name' => $module->getName() . ' ' . dmString::humanize($component->getName()), 'form_class' => $baseClass . 'Form', 'view_class' => $baseClass . 'View', 'use_component' => $this->componentExists($moduleKey, $componentKey), 'cache' => $component->isCachable());
$this->widgetTypes[$moduleKey][$componentKey] = new dmWidgetType($moduleKey, $componentKey, $widgetTypeConfig);
}
}
$cache->set('types', $this->widgetTypes);
}
}
return $this->widgetTypes;
}
开发者ID:jdart,项目名称:diem,代码行数:32,代码来源:dmWidgetTypeManager.php
示例7: checkBackground
public function checkBackground($validator, $values)
{
if ('fit' == $values['method'] && !dmString::hexColor($values['background'])) {
throw new sfValidatorErrorSchema($validator, array('background' => new sfValidatorError($validator, 'This is not a valid hexadecimal color')));
}
return $values;
}
开发者ID:runopencode,项目名称:diem-extended,代码行数:7,代码来源:dmWidgetContentImageForm.php
示例8: useSearchIndex
protected function useSearchIndex($slug)
{
if (!dmConfig::get('smart_404')) {
return false;
}
try {
$searchIndex = $this->serviceContainer->get('search_engine')->getCurrentIndex();
$queryString = str_replace('/', ' ', dmString::unSlugify($slug));
$query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
$results = $searchIndex->search($query);
$foundPage = null;
foreach ($results as $result) {
if ($result->getScore() > 0.5) {
if ($foundPage = $result->getPage()) {
break;
}
} else {
break;
}
}
if ($foundPage) {
return $this->serviceContainer->getService('helper')->link($foundPage)->getHref();
}
} catch (Exception $e) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array('Can not use search index to find redirection for slug ' . $slug, sfLogger::ERR)));
if (sfConfig::get('dm_debug')) {
throw $e;
}
}
}
开发者ID:jdart,项目名称:diem,代码行数:30,代码来源:dmPageNotFoundHandler.php
示例9: background
public function background($v)
{
if (!($hexColor = dmString::hexColor($v))) {
throw new dmException(sprintf('%s is not a valid hexadecimal color', $v));
}
return $this->setOption('background', $hexColor);
}
开发者ID:theolymp,项目名称:diem,代码行数:7,代码来源:dmMediaTagImage.php
示例10: linkToHistory
public function linkToHistory($object, $params)
{
if (!$object->getTable()->isVersionable()) {
return '';
}
return '<li class="sf_admin_action_history">' . link_to1(__($params['label']), $this->getRouteArrayForAction('history', $object), array('class' => 'sf_admin_action s16 s16_clock_history', 'title' => __($params['title'], array('%1%' => dmString::strtolower(__($this->getModule()->getName())))))) . '</li>';
}
开发者ID:rafaelgou,项目名称:diem,代码行数:7,代码来源:dmAdminModelGeneratorHelper.php
示例11: media_file_image_tag
function media_file_image_tag(DmMedia $file, $options = array()) {
$options = array_merge(array(
'width' => $file->isImage() ? 128 : 64,
'height' => $file->isImage() ? 98 : 64
), dmString::toArray($options, true));
if ($file->isImage()) {
$image = _media($file);
} else {
if (file_exists(
dmOs::join(
sfConfig::get('sf_web_dir')
.
'/dmCorePlugin/images/media/'
.
dmOs::getFileExtension($file->getFile(), false)
. '.png'
)
)) {
$image = _media('/dmCorePlugin/images/media/' . dmOs::getFileExtension($file->getFile(), false) . '.png');
} else {
$image = _media('/dmCorePlugin/images/media/unknown.png');
}
}
return $image->size($options['width'], $options['height']);
}
开发者ID:jaimesuez,项目名称:diem,代码行数:27,代码来源:DmMediaHelper.php
示例12: filterSet
/**
* Implementation of filterSet() to call set on Translation relationship to allow
* access to I18n properties from the main object.
*
* @param Doctrine_Record $record
* @param string $name Name of the property
* @param string $value Value of the property
* @return void
*/
public function filterSet(Doctrine_Record $record, $fieldName, $value)
{
$translation = $record->get('Translation');
$culture = myDoctrineRecord::getDefaultCulture();
if ($translation->contains($culture)) {
$i18n = $record->get('Translation')->get($culture);
} else {
$i18n = $record->get('Translation')->get($culture);
/*
* If translation is new
* populate it with i18n fallback
*/
if ($i18n->state() == Doctrine_Record::STATE_TDIRTY) {
if ($fallback = $record->getI18nFallBack()) {
$fallBackData = $fallback->toArray();
unset($fallBackData['id'], $fallBackData['lang']);
$i18n->fromArray($fallBackData);
}
}
}
if (!ctype_lower($fieldName) && !$i18n->contains($fieldName)) {
$underscoredFieldName = dmString::underscore($fieldName);
if (strpos($underscoredFieldName, '_') !== false && $i18n->contains($underscoredFieldName)) {
$fieldName = $underscoredFieldName;
}
}
$i18n->set($fieldName, $value);
return $value;
}
开发者ID:theolymp,项目名称:diem,代码行数:38,代码来源:dmDoctrineRecordI18nFilter.class.php
示例13: getDmConfiguration
public static function getDmConfiguration()
{
$moduleManager = dmContext::getInstance()->getModuleManager();
// homepage first
$config = array('homepage' => array('class' => 'sfRoute', 'url' => '/', 'params' => array('module' => 'dmAdmin', 'action' => 'index')));
// media library special route
if ($dmMediaLibraryModule = $moduleManager->getModuleOrNull('dmMediaLibrary')) {
$baseUrl = implode('/', array(dmString::slugify($dmMediaLibraryModule->getSpace()->getType()->getPublicName()), dmString::slugify($dmMediaLibraryModule->getSpace()->getPublicName()), dmString::slugify($dmMediaLibraryModule->getPlural())));
$config['dm_media_library_path'] = array('class' => 'sfRoute', 'url' => $baseUrl . '/path/:path', 'params' => array('module' => 'dmMediaLibrary', 'action' => 'path', 'path' => ''), 'requirements' => array('path' => '.*'));
}
// module routes
foreach ($moduleManager->getModules() as $module) {
if (!$module->hasAdmin()) {
continue;
}
$baseUrl = implode('/', array(dmString::slugify($module->getSpace()->getType()->getPublicName()), dmString::slugify($module->getSpace()->getPublicName()), dmString::slugify($module->getPlural())));
$config[$module->getUnderscore()] = array('class' => 'sfRoute', 'url' => $baseUrl . '/:action/*', 'params' => array('module' => $module->getSfName(), 'action' => 'index'));
}
// static routes
$config['default'] = array('class' => 'sfRoute', 'url' => '/+/:module/:action/*');
$config['signin'] = array('class' => 'sfRoute', 'url' => '/security/signin', 'params' => array('module' => 'dmUserAdmin', 'action' => 'signin'));
$config['signout'] = array('class' => 'sfRoute', 'url' => '/security/signout', 'params' => array('module' => 'dmUserAdmin', 'action' => 'signout'));
$config['dm_module_type'] = array('class' => 'sfRoute', 'url' => '/:moduleTypeName', 'params' => array('module' => 'dmAdmin', 'action' => 'moduleType'));
$config['dm_module_space'] = array('class' => 'sfRoute', 'url' => '/:moduleTypeName/:moduleSpaceName', 'params' => array('module' => 'dmAdmin', 'action' => 'moduleSpace'));
return $config;
}
开发者ID:jaimesuez,项目名称:diem,代码行数:26,代码来源:dmAdminRoutingConfigHandler.php
示例14: configure
public function configure(array $data)
{
$isXhr = $data['context']->getRequest()->isXmlHttpRequest();
$uri = $this->cleanUri(dmArray::get($data['server'], 'PATH_INFO', $data['server']['REQUEST_URI']));
$milliseconds = (microtime(true) - dm::getStartTime()) * 1000;
$this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'uri' => dmString::truncate($uri, 500), 'code' => (string) $data['context']->getResponse()->getStatusCode(), 'app' => (string) sfConfig::get('sf_app'), 'env' => (string) sfConfig::get('sf_environment'), 'ip' => (string) $data['server']['REMOTE_ADDR'], 'user_id' => (string) $data['context']->getUser()->getUserId(), 'user_agent' => dmString::truncate($isXhr ? '' : isset($data['server']['HTTP_USER_AGENT']) ? $data['server']['HTTP_USER_AGENT'] : '', 500), 'xhr' => (int) $isXhr, 'mem' => (string) memory_get_peak_usage(true), 'timer' => (string) sprintf('%.0f', $milliseconds), 'cache' => sfConfig::get('dm_internal_page_cached'));
}
开发者ID:jdart,项目名称:diem,代码行数:7,代码来源:dmRequestLogEntry.php
示例15: populate
/**
* Fill the field values with the page
*/
public function populate()
{
$boostValues = $this->getBoostValues();
// store the page id without indexing it
$this->store('page_id', $this->page->get('id'));
// index the page slug
$this->index('slug', dmString::unSlugify($this->page->get('slug')), $boostValues['slug']);
// index the page name
$this->index('name', $this->page->get('name'), $boostValues['name']);
// index the page title
$this->index('title', $this->page->get('title'), $boostValues['title']);
// index the page h1
$this->index('h1', $this->page->get('h1'), $boostValues['h1']);
// index the page description
$this->index('description', $this->page->get('description'), $boostValues['description']);
// index keywords only if the project uses them
if (sfConfig::get('dm_seo_use_keywords')) {
$this->index('keywords', $this->page->get('keywords'), $boostValues['keywords']);
}
// process the page body only if its boost value is not null
if ($boostValues['body']) {
$this->index('content_index', $this->getPageContentForIndex(), $boostValues['body']);
}
// store page content to display it on search results
$this->store('content', $this->getPageContentForStore());
}
开发者ID:runopencode,项目名称:diem-extended,代码行数:29,代码来源:dmSearchPageDocument.php
示例16: addPage
protected function addPage(DmPage $page)
{
$pageMenu = $this->addChild('page-' . $page->get('id'), $page)->label(dmString::escape($page->get('name')))->secure($page->get('is_secure'))->credentials($page->get('credentials'));
foreach ($page->get('__children') as $child) {
!in_array($child->id, $this->hide) && $pageMenu->addPage($child);
}
}
开发者ID:theolymp,项目名称:diem,代码行数:7,代码来源:dmSitemapMenu.php
示例17: listenToConfigUpdatedEvent
public function listenToConfigUpdatedEvent(sfEvent $event)
{
$setting = $event['setting'];
if ('internal' == dmString::strtolower($setting->groupName)) {
return;
}
$this->log(array('server' => $_SERVER, 'action' => 'update', 'type' => 'config', 'subject' => sprintf('%s = %s ( %s )', $setting->name, dmString::truncate($setting->value, 80), $event['culture'])));
}
开发者ID:theolymp,项目名称:diem,代码行数:8,代码来源:dmEventLog.php
示例18: linkToImportSentences
public function linkToImportSentences($object, $params)
{
if ($this->module->getSecurityManager()->userHasCredentials('edit', $object)) {
$title = __(isset($params['title']) ? $params['title'] : $params['label'], array('%1%' => dmString::strtolower(__($this->getModule()->getName()))), 'dm');
return '<li class="sf_admin_action_import_sentences">' . link_to1(__($params['label'], array(), $this->getI18nCatalogue()), $this->getRouteArrayForAction('importSentences', $object), array('class' => 's16 s16_save dm_import_link sf_admin_action', 'title' => $title)) . '</li>';
}
return '';
}
开发者ID:theolymp,项目名称:diem,代码行数:8,代码来源:dmCatalogueGeneratorHelper.class.php
示例19: label
public function label($label = null, $attributes = array())
{
$attributes = dmString::toArray($attributes);
$attributes['class'] = dmArray::toHtmlCssClasses(empty($attributes['class']) ? array('label') : array_merge((array) $attributes['class'], array('label')));
$label = null === $label ? $this->parent->getWidget()->getLabel($this->name) : $label;
$this->htmlBuffer .= parent::renderLabel($label, $attributes);
return $this;
}
开发者ID:runopencode,项目名称:diem-extended,代码行数:8,代码来源:dmFormField.php
示例20: generateHeader
protected function generateHeader()
{
$fields = array();
foreach ($this->getFields() as $field => $fieldName) {
$fields[] = $this->i18n->__(dmString::humanize($fieldName));
}
return $fields;
}
开发者ID:theolymp,项目名称:diem,代码行数:8,代码来源:dmDoctrineTableExport.php
注:本文中的dmString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论