本文整理汇总了PHP中dmArray::get方法的典型用法代码示例。如果您正苦于以下问题:PHP dmArray::get方法的具体用法?PHP dmArray::get怎么用?PHP dmArray::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmArray
的用法示例。
在下文中一共展示了dmArray::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrls
protected function getUrls()
{
$urls = array('/');
$routing = $this->context->getRouting();
foreach ($this->context->getModuleManager()->getModules() as $module) {
if (!$routing->hasRouteName($module->getUnderscore())) {
continue;
}
$moduleUrl = $routing->generate($module->getUnderscore());
$urls[] = $moduleUrl;
if ($module->hasModel() && $module->getTable()->hasField('id')) {
$records = $module->getTable()->createQuery('t')->select('t.id, RANDOM() AS rand')->orderBy('rand')->limit(2)->fetchArray();
foreach ($records as $record) {
$urls[] = $moduleUrl . '/edit/pk/' . $record['id'];
}
}
}
foreach ($this->context->getModuleManager()->getTypes() as $type) {
$urls[] = $this->context->getController()->genUrl($routing->getModuleTypeUrl($type));
foreach ($type->getSpaces() as $space) {
$urls[] = $this->context->getController()->genUrl($routing->getModuleSpaceUrl($space));
}
}
$uriPrefixLength = strlen(dmArray::get(dmArray::get($routing->getOptions(), 'context'), 'prefix'));
foreach ($urls as $index => $url) {
$urls[$index] = substr($url, $uriPrefixLength);
}
return $urls;
}
示例2: executeCommand
public function executeCommand(sfWebRequest $request)
{
$command = trim($request->getParameter("dm_command"));
if (substr($command, 0, 2) == "sf") {
$command = substr($command, 3);
$exec = sprintf('%s "%s" %s --color', sfToolkit::getPhpCli(), dmProject::getRootDir() . '/symfony', $command);
} else {
$options = substr(trim($command), 0, 2) == 'll' || substr(trim($command), 0, 2) == 'ls' ? '--color' : '';
$parts = explode(" ", $command);
$parts[0] = dmArray::get($this->getAliases(), $parts[0], $parts[0]);
$command = implode(" ", $parts);
$parts = explode(" ", $command);
$command = dmArray::get($this->getAliases(), $command, $command);
if (!in_array($parts[0], $this->getCommands())) {
return $this->renderText(sprintf("%s<li>This command is not available. You can do: <strong>%s</strong></li>", $this->renderCommand($command), implode(' ', $this->getCommands())));
}
$exec = sprintf("%s {$options}", $command);
}
ob_start();
passthru($exec . ' 2>&1', $return);
$raw = dmAnsiColorFormatHtmlRenderer::render(ob_get_clean());
$arr = explode("\n", $raw);
$res = $this->renderCommand($command);
foreach ($arr as $a) {
$res .= "<li class='dm_result_command'><pre>" . $a . "</pre></li>";
}
return $this->renderText($res);
}
示例3: configure
public function configure(array $options = array())
{
$options['default'] = null;
foreach ($options['list'] as $themeName => $themeConfig) {
// enabled options defaults to true
if (null === dmArray::get($themeConfig, 'enabled')) {
$options['list'][$themeName]['enabled'] = true;
}
// first enabled theme is the default theme
if (null === $options['default'] && $options['list'][$themeName]['enabled']) {
$options['default'] = $themeName;
}
// path is renamed to dir BC 5.0_BETA6
if (isset($options['list'][$themeName]['path'])) {
$options['list'][$themeName]['dir'] = $options['list'][$themeName]['path'];
unset($options['list'][$themeName]['path']);
}
// theme key is the theme name
$options['list'][$themeName]['name'] = $themeName;
}
if (null === $options['default']) {
throw new dmException('No theme is enabled!');
}
return parent::configure($options);
}
示例4: 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;
}
示例5: executeSaveFile
public function executeSaveFile(dmWebRequest $request)
{
// modify existing media
if ($mediaId = dmArray::get($request->getParameter('dm_admin_media_form'), 'id')) {
$this->forward404Unless($media = dmDb::table('DmMedia')->find($mediaId));
$form = new DmAdminMediaForm($media);
} else {
$media = null;
$this->forward404Unless($folder = dmDb::table('DmMediaFolder')->find($request->getParameter('folder_id')));
if (!$folder->isWritable()) {
$this->getUser()->logAlert($this->getI18n()->__('Folder %1% is not writable', array('%1%' => $folder->fullPath)));
}
$form = new DmAdminMediaForm();
$form->setDefault('dm_media_folder_id', $folder->id);
}
if ($request->isMethod('post') && $form->bindAndValid($request)) {
$redirect = $form->getValue('file') || $media->dm_media_folder_id != $form->getValue('dm_media_folder_id');
$media = $form->save();
if ($redirect) {
$this->getUser()->setFlash('dm_media_open', $media->id, false);
return $this->renderText($this->getRouting()->getMediaUrl(dmDb::table('DmMediaFolder')->find($media->dm_media_folder_id)));
}
}
$action = $media ? 'dmMediaLibrary/saveFile' : 'dmMediaLibrary/saveFile?folder_id=' . $folder->id;
return $this->renderText($form->render('.dm_form.list.little action="' . $action . '"'));
}
示例6: getWidgetValues
public function getWidgetValues()
{
$values = parent::getWidgetValues();
$values['items'] = array();
foreach(dmArray::get($values, 'link', array()) as $index => $link)
{
$values['items'][] = array(
'link' => $values['link'][$index],
'text' => $values['text'][$index],
'secure' => (int) !empty($values['secure'][$index]),
'nofollow' => (int) !empty($values['nofollow'][$index]),
'depth' => $values['depth'][$index]
);
}
unset(
$values['link'],
$values['text'],
$values['secure'],
$values['nofollow'],
$values['depth']
);
return $values;
}
示例7: 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'));
}
示例8: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$this->logSection('Diem Extended', 'Setup ' . dmProject::getKey());
$this->dispatcher->notify(new sfEvent($this, 'dm.setup.before', array('clear-db' => $options['clear-db'])));
// don't use cache:clear task because it changes current app & environment
@sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'))) {
$this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'));
}
if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'))) {
$this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'));
}
if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineTable.php'))) {
$this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineTable.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineTable.php'));
}
$this->runTask('doctrine:build', array(), array('model' => true));
if ($options['clear-db'] || $options['clear-tables'] || $this->isProjectLocked()) {
$this->reloadAutoload();
if ($options['clear-db']) {
$this->runTask('doctrine:drop-db', array(), array('env' => $options['env'], 'no-confirmation' => dmArray::get($options, 'no-confirmation', false)));
} else {
$this->runTask('dm:drop-tables', array(), array('env' => $options['env']));
}
if ($options['clear-db'] && ($ret = $this->runTask('doctrine:build-db', array(), array('env' => $options['env'])))) {
return $ret;
}
$this->runTask('doctrine:build-sql', array(), array('env' => $options['env']));
$this->runTask('doctrine:insert-sql', array(), array('env' => $options['env']));
} else {
$this->runTask('dm:upgrade', array(), array('env' => $options['env']));
}
$this->reloadAutoload();
$this->withDatabase();
$this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
$this->getContext()->reloadModuleManager();
$this->runTask('doctrine:build-forms', array(), array('generator-class' => 'dmDoctrineFormGenerator'));
$this->runTask('doctrine:build-filters', array(), array('generator-class' => 'dmDoctrineFormFilterGenerator'));
$this->runTask('dm:publish-assets');
$this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
$this->reloadAutoload();
$this->getContext()->reloadModuleManager();
$this->runTask('dmAdmin:generate', array(), array('env' => $options['env']));
if (!$options['dont-load-data']) {
$this->runTask('dm:data', array(), array('load-doctrine-data' => $options['load-doctrine-data'], 'env' => $options['env']));
}
$this->logSection('Diem Extended', 'generate front modules');
if (!($return = $this->context->get('filesystem')->sf('dmFront:generate --env=' . dmArray::get($options, 'env', 'dev')))) {
$this->logBlock(array('Can\'t run dmFront:generate: ' . $this->context->get('filesystem')->getLastExec('output'), 'Please run "php symfony dmFront:generate" manually to generate front templates'), 'ERROR');
}
$this->runTask('dm:permissions');
// fix db file permissions
if ('Sqlite' === Doctrine_Manager::connection()->getDriverName()) {
$this->filesystem->chmod(sfConfig::get('sf_data_dir'), 0777, 00);
}
$this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
$this->dispatcher->notify(new sfEvent($this, 'dm.setup.after', array('clear-db' => $options['clear-db'])));
$this->logBlock('Setup successful', 'INFO_LARGE');
$this->unlockProject();
}
示例9: getBrowser
/**
* Guess user's browser
* @return dmBrowser browser object
*/
public function getBrowser()
{
if (!$this->isBrowserConfigured) {
$this->browser->configureFromUserAgent(dmArray::get($_SERVER, 'HTTP_USER_AGENT'));
$this->isBrowserConfigured = true;
}
return $this->browser;
}
示例10: configure
public function configure(array $data)
{
$userId = dmArray::get($data, 'user_id', $this->serviceContainer->getService('user')->getUserId());
if (!$userId && dmConfig::isCli()) {
$userId = 'task';
}
$this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'ip' => (string) $this->getCurrentRequestIp(), 'session_id' => (string) session_id(), 'user_id' => (string) $userId, 'action' => (string) $data['action'], 'type' => (string) $data['type'], 'subject' => dmString::truncate($data['subject'], 500), 'record' => isset($data['record']) ? get_class($data['record']) . ':' . $data['record']->get('id') : '');
}
示例11: getWidgetValues
public function getWidgetValues()
{
$values = parent::getWidgetValues();
if (dmArray::get($values, 'removeMedia')) {
$values['mediaId'] = null;
}
unset($values['removeMedia']);
return $values;
}
示例12: renderPartial
protected function renderPartial(array $vars)
{
if ($this->isCachable() && $this->context->getViewCacheManager()) {
list($partialModule, $partialAction) = $this->getPartialModuleAction();
$this->context->getViewCacheManager()->addCache($partialModule, '_' . $partialAction, array('withLayout' => false, 'lifeTime' => 86400, 'clientLifeTime' => 86400, 'contextual' => !$this->isStatic(), 'vary' => array(dmArray::get($this->widget, 'id'), $this->getService('user')->getUserId(), $this->getService('user')->getCulture())));
}
// add dm_widget to the component/partial vars
$vars['dm_widget'] = $this->widget;
return $this->doRenderPartial($vars);
}
示例13: getResultsPager
protected function getResultsPager(array $vars)
{
$results = $this->getService('search_engine')->search($vars['query']);
if (empty($results)) {
return null;
}
$pager = new dmSearchPager($results, dmArray::get($vars, 'maxPerPage', 99999));
$pager->setPage($this->getService('request')->getParameter('page', 1));
$pager->init();
return $this->getService('front_pager_view')->setPager($pager)->setOption('navigation_top', dmArray::get($vars, 'navTop'))->setOption('navigation_bottom', dmArray::get($vars, 'navBottom'))->setBaseHref($this->getService('request')->getUri());
}
示例14: renderBodyTag
public function renderBodyTag($options = array())
{
$options = dmString::toArray($options);
$options['class'] = dmArray::toHtmlCssClasses(array_merge(dmArray::get($options, 'class', array()), array(
'page_'.$this->page->get('module').'_'.$this->page->get('action'),
$this->page->getPageView()->getLayout()->get('css_class')
)));
return parent::renderBodyTag($options);
}
示例15: getBigLorem
public static function getBigLorem($nbParagraphs = null)
{
$lorem = self::getLoremText();
if (null === $nbParagraphs) {
$nbParagraphs = 1;
}
$paragraphs = array();
for ($it = 0; $it < $nbParagraphs; $it++) {
$paragraphs[] = dmArray::get($lorem, array_rand($lorem));
}
return implode("\n", $paragraphs);
}