本文整理汇总了PHP中D类的典型用法代码示例。如果您正苦于以下问题:PHP D类的具体用法?PHP D怎么用?PHP D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testSiblings
public function testSiblings()
{
$node = new Node();
$node->appendChild($a = new A());
$b = new B($node);
$node->prependChild($c = new C());
$node->appendChild($d = new D());
$a->remove();
$this->assertSame(null, $c->getPreviousSibling());
$this->assertSame($b, $c->getNextSibling());
$this->assertSame(null, $d->getNextSibling());
$this->assertSame($b, $d->getPreviousSibling());
$this->assertSame($c, $b->getPreviousSibling());
$this->assertSame($d, $b->getNextSibling());
}
开发者ID:talesoft,项目名称:tale-tree,代码行数:15,代码来源:NodeTest.php
示例2: getValue
public static function getValue($value, $settings, $model)
{
// Check if the src is set and the converted values are not - this means we need to check for
// the progress file and possibly update the database
if (is_array($value) && isset($value['src']) && strlen($value['src']) > 0 && (!isset($value['converted']) || empty($value['converted']))) {
// See if the progress file exists
$path = DOCROOT . $value['src'];
if (file_exists($path . '.progress')) {
$value['progress'] = json_decode(file_get_contents($path . '.progress'));
} else {
// It doesn't exist - populate the field
if (isset($value['progress'])) {
unset($value['progress']);
}
$path_info = pathinfo($value['src']);
$value['poster'] = $path_info['dirname'] . '/' . $path_info['basename'] . '.jpg';
$value['converted'] = array('mp4' => $path_info['dirname'] . '/converted/' . $path_info['filename'] . '.mp4', 'webm' => $path_info['dirname'] . '/converted/' . $path_info['filename'] . '.webm');
//$class = \CMF::getClass($model);
$field_name = $settings['mapping']['fieldName'];
$model->set($field_name, $value);
\D::manager()->persist($model);
\D::manager()->flush();
}
}
return $value;
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:26,代码来源:Video.php
示例3: enableListener
public static function enableListener()
{
if (empty(static::$listener)) {
return;
}
\D::manager()->getEventManager()->addEventSubscriber(static::$listener);
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:7,代码来源:Timestampable.php
示例4: main
function main()
{
$c = new C();
B::test($c);
C::test($c);
D::test($c);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:typehint_lsb_self.php
示例5: main
function main()
{
$c = new C();
$d = new D();
$c->foo();
$d->foo();
echo "**************\n";
$c->bar();
$d->bar();
echo "**************\n";
C::foo();
D::bar();
echo "**************\n";
$d->yar();
D::yar();
}
开发者ID:badlamer,项目名称:hhvm,代码行数:16,代码来源:static_new.php
示例6: __callStatic
public static function __callStatic($name, $args)
{
if (!self::$instance) {
self::$instance = new D\ump();
}
return call_user_func_array([self::$instance, $name], $args);
}
开发者ID:aronduby,项目名称:dump,代码行数:7,代码来源:D.php
示例7: removeOldKeys
/**
* Purge all expired API keys from the database
*/
public function removeOldKeys()
{
$keys = \CMF\Model\User\Apikey::select('item')->andWhere('item.expires_at < :now')->setParameter('now', new \DateTime())->getQuery()->getResult();
foreach ($keys as $key) {
\D::manager()->remove($key);
}
\D::manager()->flush();
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:11,代码来源:session.php
示例8: getModels
public function getModels()
{
$models = D::queryGoodsModels(array('make' => $this->make, 'series' => $this->series, 'year' => $this->year));
// if (!empty($models)) {
// $add_model = array(array("modelId" => "ALL", "name" => "ALL"));
// $models = array_merge($add_model, $models);
// }
return $models;
}
开发者ID:zwq,项目名称:unpei,代码行数:9,代码来源:WGoodsModel.php
示例9: cleanOld
public static function cleanOld()
{
$urls = \CMF\Model\URL::select('item')->getQuery()->getResult();
$deleted = 0;
foreach ($urls as $url) {
$item = $url->item();
if (empty($item)) {
\D::manager()->remove($url);
$deleted++;
}
}
\D::manager()->flush();
return $deleted;
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:14,代码来源:URL.php
示例10: action_languageCanonicals
public function action_languageCanonicals()
{
$lang = \Config::get('language');
$em = \D::manager();
if (empty($lang)) {
throw new \Exception("You do not have set any language for this site , this action is not available");
}
$canonicalLanguage = "";
if (isset($_SERVER["HTTP_CONTENT_LANGUAGE"])) {
$canonicalLanguage = $_SERVER["HTTP_CONTENT_LANGUAGE"];
if ($canonicalLanguage == $lang) {
throw new \Exception("Canonical Language id the same as Main site language");
}
} else {
throw new \Exception("The Request has got not language set");
}
$jsonObject = null;
try {
$jsonObject = json_decode(file_get_contents('php://input'));
} catch (\Exception $e) {
}
if (!empty($jsonObject) && !empty($jsonObject->data)) {
foreach ($jsonObject->data as $table => $items) {
foreach ($items as $canonical) {
$class = $canonical->class;
$item = $class::find($canonical->id);
if (!empty($item) && !empty($item->settings)) {
$settings = $item->settings;
if (!isset($settings['languages'])) {
$settings['languages'] = array();
}
if (isset($canonical->url)) {
if (!isset($settings['languages'][$canonicalLanguage])) {
$settings['languages'][$canonicalLanguage] = \Uri::base(false) . $item->url;
}
$settings['languages'][$canonicalLanguage] = $canonical->url;
} else {
if (isset($settings['languages'][$canonicalLanguage])) {
unset($settings['languages'][$canonicalLanguage]);
}
}
$item->set('settings', $settings);
$em->persist($item);
}
}
}
}
$em->flush();
exit(true);
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:50,代码来源:resource.php
示例11: __construct
public function __construct($metadata, $model, $prefix = '', $prepopulate = array(), $exclude = array(), $disable_groups = false, $disable_widgets = false, $extra_settings = null)
{
$class_name = $metadata->name;
$model_id = $model->id;
$this->table_name = $metadata->table['name'];
$this->prepopulate = \Arr::merge(\Input::get(), $prepopulate);
$this->exclude = $exclude;
$this->disable_groups = $disable_groups;
$this->disable_widgets = $disable_widgets;
$this->title = $model_id && method_exists($model, 'getFormTitle') ? $model->getFormTitle() : $class_name::singular();
if (\Input::param('alias', false) !== false) {
$this->icon = 'link';
$this->plural = 'Links';
$this->singular = 'Link';
} else {
$this->icon = $class_name::icon();
$this->plural = $class_name::plural();
$this->singular = $class_name::singular();
}
// Tabs, Groups, Fields
$this->tabs = $class_name::tabs();
$this->groups = $class_name::groups();
$this->default_tab = $class_name::defaultTab();
$this->default_group = $class_name::defaultGroup();
// Merge in extra field settings
$this->fields = \Admin::getFieldSettings($class_name);
if ($extra_settings !== null && is_array($extra_settings)) {
$this->fields = \Arr::merge($this->fields, $extra_settings);
}
$this->validator_meta = \D::validator()->getMetadataFactory()->getMetadataFor($class_name);
// Merge any DB settings into the mix...
$model_settings = $model->settings;
if (is_array($model_settings)) {
$_model_settings = array();
foreach ($model_settings as $key => $value) {
if (is_array($value) && ($metadata->hasField($key) || $metadata->hasAssociation($key))) {
$_model_settings[$key] = $value;
}
}
$this->fields = \Arr::merge($this->fields, $_model_settings);
}
// The field data
$this->processFieldSettings($metadata, $model, $prefix);
// The group data
$this->processGroups();
// The form structure
$this->processFormStructure();
$this->assets['js'] = array_unique($this->assets['js']);
$this->assets['css'] = array_unique($this->assets['css']);
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:50,代码来源:ModelForm.php
示例12: newDb
public function newDb($name) {
$database = $this->libs->Config->get('databases', $name);
//Sweetframework::getClass('lib', 'databases/drivers/' . $database['driver'], );
//App::includeLibrary('Databases/Drivers/' . $database['driver'] . '.php');
$this->setCurrentDb($name);
$this->databases[$name] = Sweetframework::loadClass('lib', 'databases/drivers/' . $database['driver'], $database); //new $database['driver']($database);
if(!$this->databases[$name]->connect()) {
D::warn('failed to connect to the db');
}
}
开发者ID:ajcates,项目名称:Sweet-Framework-old,代码行数:15,代码来源:Databases.php
示例13: startQuery
public function startQuery($sql, array $params = null, array $types = null)
{
if ($this->logger) {
$this->logger->startQuery($sql, $params, $types);
}
// Store select queries for later use
if (substr($sql, 0, 6) == 'SELECT') {
if ($params) {
// Attempt to replace placeholders so that we can log a final SQL query for profiler's EXPLAIN statement
// (this is not perfect-- getPlaceholderPositions has some flaws-- but it should generally work with ORM-generated queries)
$is_positional = is_numeric(key($params));
list($sql, $params, $types) = \Doctrine\DBAL\SQLParserUtils::expandListParameters($sql, $params, $types);
if (empty($types)) {
$types = array();
}
$placeholders = \Doctrine\DBAL\SQLParserUtils::getPlaceholderPositions($sql, $is_positional);
if ($is_positional) {
$map = array_flip($placeholders);
} else {
$map = array();
foreach ($placeholders as $name => $positions) {
foreach ($positions as $pos) {
$map[$pos] = $name;
}
}
}
ksort($map);
$src_pos = 0;
$final_sql = '';
$first_param_index = key($params);
foreach ($map as $pos => $replace_name) {
$final_sql .= substr($sql, $src_pos, $pos - $src_pos);
if ($sql[$pos] == ':') {
$src_pos = $pos + strlen($replace_name);
$index = trim($replace_name, ':');
} else {
$src_pos = $pos + 1;
$index = $replace_name + $first_param_index;
}
$final_sql .= \D::manager()->getConnection()->quote($params[$index], \Arr::get($types, $index));
}
$final_sql .= substr($sql, $src_pos);
$this->queries[] = $final_sql;
} else {
$this->queries[] = $sql;
}
}
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:48,代码来源:QueryLogger.php
示例14: set
function set($name) {
//@todo rename this to just set
$newPlace = 'app/themes/' . $name;
D::log(LOC . '/' . $newPlace, 'new Place');
if(is_dir(LOC . '/' . $newPlace)) {
if(substr(URL, -1) == '?') {
T::$url = $this->themeUrl = substr(URL, 0, -1) . $newPlace;
} else {
T::$url = $this->themeUrl = URL . $newPlace;
}
T::$loc = LOC . '/' . $newPlace;
//$this->libs->Config->set('site', 'theme', $newPlace);
return true;
} else {
D::error('Theme doesn\'t exist');
}
}
开发者ID:ajcates,项目名称:Sweet-Framework-old,代码行数:17,代码来源:Theme.php
示例15: instance
/** inheritdoc */
public static function instance()
{
$called_class = get_called_class();
if (!isset($called_class::$instances[$called_class])) {
$result = $called_class::select('item, start_page')->leftJoin('item.start_page', 'start_page')->setMaxResults(1)->getQuery()->getResult();
if (count($result) == 0) {
// Create the item if it doesn't exist
$result = new $called_class();
$result->blank();
\D::manager()->persist($result);
\D::manager()->flush();
$called_class::$instances[$called_class] = $result;
} else {
$called_class::$instances[$called_class] = $result[0];
}
}
return $called_class::$instances[$called_class];
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:19,代码来源:Settings.php
示例16: set
function set($name) {
//@todo rename this to just set
$newPlace = 'themes/' . $name;
D::log($name, 'Theme Set');
// D::log(URL, 'URL');
if(is_dir(APP_FOLDER . '/' . $newPlace)) {
if(defined('URL')) {
if(substr(URL, -1) == '?') {
T::$url = $this->themeUrl = substr(URL, 0, -1) . APP_NAME . '/' . $newPlace . '/';
} else {
T::$url = $this->themeUrl = URL . APP_NAME . '/' . $newPlace . '/';
}
}
T::$loc = $this->themeLoc = APP_FOLDER . '/' . $newPlace;
//$this->libs->Config->set('site', 'theme', $newPlace);
return true;
} else {
D::error('Theme doesn\'t exist');
}
}
开发者ID:noblejay,项目名称:Sweet-Framework,代码行数:20,代码来源:Theme.php
示例17: query
function query($sql, $returnType) {
if($this->prepared == false) {
$this->prepare($sql);
}
//echo "\n SQL call = " . $sql . "\n";
$this->queries[] = $sql;
$this->result = $this->connection->query($sql);
//D::log($this->connection->error, 'db error');
D::log($sql, 'Sql call');
if(!empty($this->connection->error)) {
D::report('There is something wrong with the sql.', $this->connection->error);
}
$this->prepared = false;
//return $this->result->fetch_all(MYSQLI_ASSOC);
$return = array();
switch ($returnType){
case 'object':
while($value = $this->result->fetch_object()) {
$return[] = $value;
}
//D::log($return);
return $return;
case 'assoc':
while($value = $this->result->fetch_assoc()) {
$return[] = $value;
}
return $return;
case 'raw':
return $this->result;
default:
return true;
}
}
开发者ID:ajcates,项目名称:Sweet-Framework-old,代码行数:39,代码来源:My_SQLi.php
示例18: properJsonDecode
function properJsonDecode($json) {
//maybe if we check something on the left we can validate that the value on the right is actaully a value and not part of a string.
$return = json_decode(D::log(preg_replace('@"(\w*)"\s*:\s*(-?\d{9,})\s*([,|\}])@', '"$1":"$2"$3', $json), 'raw json') );
switch(json_last_error()) {
case JSON_ERROR_DEPTH:
$echo = ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_CTRL_CHAR:
$echo = ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
$echo = ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_NONE:
$echo = ' - No errors';
break;
}
D::growl($echo, 'json error');
return $return;
}
开发者ID:noblejay,项目名称:Sweet-Framework,代码行数:22,代码来源:misc.php
示例19: test
function test()
{
D::D();
$X = "D";
$m = "D";
D::$m();
$X::$m();
$X::$m();
G::D();
J::D();
J::J();
$X = "G";
$m = "D";
G::$m();
$X::$m();
$X = "J";
$m = "D";
J::$m();
$X::$m();
$m = "J";
J::$m();
$X::$m();
}
开发者ID:ezoic,项目名称:hhvm,代码行数:23,代码来源:FPushClsMethod.php
示例20: pageTree
protected function pageTree($model = 'Model_Page_Base', $label = null, $active_url = null, $extra_fields = null)
{
$extra_fields_str = !is_null($extra_fields) ? ', page.' . implode(', page.', $extra_fields) : '';
if ($model == 'Model_Page_Base') {
$extra_fields_str = ', TYPE(page) AS type';
}
$nodes = $model::select('page.id, page.title, page.menu_title, page.lvl, page.lft, page.rgt' . $extra_fields_str . ', url.url, url.slug', 'page')->leftJoin('page.url', 'url')->where('page.lvl > 0')->andWhere('page.visible = true')->orderBy('page.root, page.lft', 'ASC')->getQuery();
// Set the query hint if multi lingual!
if (\CMF\Doctrine\Extensions\Translatable::enabled()) {
$nodes->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
}
$nodes = $nodes->getArrayResult();
$root_label = $label ? $label . '_level1' : 'level1';
$crumbs_label = $label ? $label . '_crumbs' : 'crumbs';
$uri = $active_url ? $active_url : \CMF::link(\CMF::original_uri());
$nodes = \D::manager()->getRepository($model)->buildTree($nodes, array());
$this->{$crumbs_label} = array();
$this->processNodes($nodes, $uri, 1, $label, $model);
$crumbs = $this->{$crumbs_label};
ksort($crumbs);
$this->{$crumbs_label} = $crumbs;
return $this->{$root_label} = $nodes;
}
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:23,代码来源:Base.php
注:本文中的D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论