Inheritance: extends C
示例#1
0
 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());
 }
示例#2
0
 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;
 }
示例#3
0
 public static function enableListener()
 {
     if (empty(static::$listener)) {
         return;
     }
     \D::manager()->getEventManager()->addEventSubscriber(static::$listener);
 }
示例#4
0
function main()
{
    $c = new C();
    B::test($c);
    C::test($c);
    D::test($c);
}
示例#5
0
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();
}
示例#6
0
文件: D.php 项目: aronduby/dump
 public static function __callStatic($name, $args)
 {
     if (!self::$instance) {
         self::$instance = new D\ump();
     }
     return call_user_func_array([self::$instance, $name], $args);
 }
示例#7
0
 /**
  * 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();
 }
示例#8
0
文件: WGoodsModel.php 项目: zwq/unpei
 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;
 }
示例#9
0
文件: d.php 项目: rhrn/apirn
 private static function out($return)
 {
     if (self::$enable) {
         self::$out = '<pre>' . self::$out . '</pre>';
         if ($return) {
             return self::$out;
         } else {
             echo self::$out;
         }
     }
 }
示例#10
0
 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;
 }
示例#11
0
 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);
 }
示例#12
0
 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']);
 }
示例#13
0
	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');
		}
	}
示例#14
0
 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;
         }
     }
 }
示例#15
0
	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');
		}
	}
示例#16
0
 /** 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];
 }
示例#17
0
	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');
		}
	}
示例#18
0
	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;
		}
		
	}
示例#19
0
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;
}
示例#20
0
 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();
 }
示例#21
0
 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;
 }
示例#22
0
var_dump($c2);
var_dump(isset($c2->prop));
echo "---------- unsetting \$this ------------\n";
class D
{
    public function f()
    {
        echo "Inside " . __METHOD__ . "\n";
        var_dump(isset($this));
        unset($this);
        var_dump(isset($this));
        $this->g();
        // use $this to call sibling instance method
    }
    private function g()
    {
        echo "Inside " . __METHOD__ . "\n";
        var_dump(isset($this));
    }
}
$d = new D();
$d->f();
echo "---------- unsetting array elements ------------\n";
$a = array(10, 20, "xx" => 30);
print_r($a);
unset($a[1]);
print_r($a);
unset($a[10]);
print_r($a);
unset($a["Xx"]);
print_r($a);
示例#23
0
	function query($sql, $returnType=null) {
		if($this->prepared == false) {
			$this->prepare($sql);
		}
		//echo "\n SQL call = " . $sql . "\n";
		
		$this->queries[] = $sql;
	//	$this->result = $this->connection->query($sql);
		D::log("\n" . $sql, 'SQL call');
		
		$this->result = mysql_query($sql, $this->connection);
		
		$this->prepared = false;
		
		if(!$this->result) {
			D::stack();
			D::log(mysql_error($this->connection), 'SQL Errors');
			return false;
		}
		
		$returnArray = array();
/* 	@todo
get rid of this switch and use an array of functions instead.
	 */
	 	if(!isset($returnType)) {
	 		return true;
	 	}
		switch ($returnType) {
			case 'object':
				if(!is_resource($this->result)) {
					D::stackTrace();
				}
				while($row = mysql_fetch_object($this->result)) {
					$returnArray[] = $row;
				}
				return $returnArray;
					
				
				break;
			case 'assoc':
				while($row = mysql_fetch_assoc($this->result)) {
					$returnArray[] = $row;
				}
				return $returnArray;
				break;
			case 'driver':
				return $this->result;
			break;
			case 'raw':
				return $this->result;
				break;
			default:
				return true;
		}
	}
        echo "Accessing X from D:\n";
        var_dump(get_class_methods("X"));
    }
}
class X
{
    private function privX()
    {
    }
    protected function protX()
    {
    }
    public function pubX()
    {
    }
    public static function testFromX()
    {
        echo "Accessing C from X:\n";
        var_dump(get_class_methods("C"));
        echo "Accessing D from X:\n";
        var_dump(get_class_methods("D"));
        echo "Accessing X from X:\n";
        var_dump(get_class_methods("X"));
    }
}
echo "Accessing D from global scope:\n";
var_dump(get_class_methods("D"));
C::testFromC();
D::testFromD();
X::testFromX();
echo "Done";
示例#25
0
<?php

// Invocation of a static class method of a superclass
// Class *definition* is interpreted
eval(<<<PHP
\tclass C
\t{
\t\tstatic function foo()
\t\t{
\t\t\techo "C::foo()
";
\t\t}
\t}

\tclass D extends C
\t{
\t}
PHP
);
D::foo();
示例#26
0
    .chose{font:13px Arial;display:block; float:left; height:25px;line-height:30px; padding-left:10px; margin:2px 0}
    .choseXc{display:block;float:right;  margin-right: 7px;margin-top: 10px;} /*border:1px solid #e1e1e1;width:20px;height:20px;*/
    .series_title{
        width: 200px;white-space: nowrap;overflow: hidden; text-overflow: ellipsis;
    }
</style>
<div class="pop">
    <div id="make-car-m" class="selectDiv4 active" >
        <div class="selectpop ass-items" style="clear:both; overflow:auto;">
            <div class="car_brand" style=" clear:both; overflow:auto;">
                <span class="chose">请选择适用车系</span>
                <p style="clear:both"></p>
                <div class="left_AA" style="float:left;">
                    <ul style="list-style:none; margin:0;padding-left:10px; height: 200px; overflow:hidden" >
                        <?php 
$makes = D::queryGoodsMakes();
?>
                        <?php 
if ($makes) {
    ?>
                            <?php 
    foreach ($makes as $key => $value) {
        ?>
                                <?php 
        $piny2[] = substr($value['pinyin'], 0, 1);
        ?>
                            <?php 
    }
    ?>
                        <?php 
}
示例#27
0
    {
        $this->p = 'changed in D';
    }
}
echo "Unset and recreate a superclass's private property:\n";
$d = new D();
$d->unsetPrivate();
$d->setPrivate();
var_dump($d);
echo "\nUnset superclass's private property, and recreate it as public in subclass:\n";
$d = new D();
$d->unsetPrivate();
$d->setP();
var_dump($d);
echo "\nUnset superclass's private property, and recreate it as public at global scope:\n";
$d = new D();
$d->unsetPrivate();
$d->p = 'this will create a public property';
var_dump($d);
echo "\n\nUnset and recreate a private property:\n";
$c = new C();
$c->unsetPrivate();
$c->setPrivate();
var_dump($c);
echo "\nUnset a private property, and attempt to recreate at global scope (expecting failure):\n";
$c = new C();
$c->unsetPrivate();
$c->p = 'this will fail';
var_dump($c);
?>
==Done==
示例#28
0
<?php

if ($a == 'B' & $b != null && $c->C(D::E() . 'F')) {
    $d++;
}
示例#29
0
<?php

$a = $b <=> $c->d;
$a = $b <=> $c->d();
$a = $b <=> D::E;
$a = $b <=> D::E();
$a = $b <=> D::$E;
示例#30
0
<?php

class C
{
    public static function foo()
    {
        static $x = 0;
        ++$x;
        var_dump($x);
    }
}
class D extends C
{
    public static function callByParent()
    {
        parent::foo();
    }
}
C::foo();
C::foo();
C::foo();
D::foo();
D::foo();
D::callByParent();
D::callByParent();