コード例 #1
0
ファイル: CreativeWork.php プロジェクト: nmp36/OnlineRecipe
  function CreativeWork() {
    parent::__construct();
    $this->about->tag->tagtype = 'span';
    $this->author->tag->tagtype = 'span';
    $this->setaboutAttributes('about');
    $this->setauthorAttributes('author');
}
コード例 #2
0
 public function __construct()
 {
     parent::__construct();
     $keys = ['author', 'publisher'];
     foreach ($keys as $key) {
         $this->properties[$key] = null;
     }
 }
コード例 #3
0
 /**
  * check if values $_REQUEST[''] exist then - get thing by id(existing thing)
  * if values not exist then create a new thing and assigns to the friend whose id is set
  * @return array
  */
 protected function run()
 {
     if (array_key_exists('id', $_REQUEST) and $_REQUEST['id'] > 0) {
         $thing = Things::getThingByID($_REQUEST['id']);
     } else {
         $thing = new Thing();
         $thing->setFriendID($_REQUEST['friendid']);
     }
     /**
      * if $_POST_[""] is not empty then set the values into the template
      * else set error massage if one of the $_POST[""] is empty
      */
     if (!empty($_POST["description"]) and !empty($_POST["statebeforelent"])) {
         $thing->setDescription($_POST["description"]);
         $thing->setStateBeforeLent($_POST["statebeforelent"]);
         $thing->setDateOfLent(date('Y-m-d'));
         /**
          * records can be saved after editing or creating
          * exit the program after a successful storage
          * error massage when one of the $_POST fields is empty
          */
         if ($thing->save()) {
             header('location:index.php?module=lentthingslist&friendid=' . $thing->getFriendId());
             exit;
         } else {
             $var = array('fehler' => "Etwas stimmt mit der Eingabe nicht!");
         }
     } elseif (!empty($_POST["description"]) or !empty($_POST["statebeforelent"])) {
         $var = array('fehler' => "Es sind nicht alle Datenfelder ausgefüllt");
     }
     $var['thing'] = $thing;
     return $var;
 }
コード例 #4
0
ファイル: character.php プロジェクト: nexgenta/weaver
 protected function rdfLinks($doc, $request)
 {
     parent::rdfLinks($doc, $request);
     $events = $this->featuredInEvents();
     foreach ($events as $ev) {
         $g = $doc->graph($request->root . $ev->instanceRelativeURI, 'http://purl.org/NET/c4dm/event.owl#Event');
         $g['ev:agent'] = new RDFURI($request->root . $this->__get('instanceRelativeURI'));
     }
 }
コード例 #5
0
ファイル: ThingsController.php プロジェクト: nchamp/mvc
  public function show($id) {
    $this->template->id = $id;

    // get the thing with id = $id
    $things = Thing::retrieve(array('id' => $id));
    if (count($things) == 1) {
      $this->template->thing = $things[0];
    }
    $this->template->id = $id;

    $this->template->display('show.html.php');
  }
コード例 #6
0
ファイル: option.php プロジェクト: rajtrivedi2001/shopify_app
 public function getByProduct($product)
 {
     $this->db->select();
     $this->db->from('thing');
     $this->db->where('thing_id', $product->getThing()->getId());
     $query = $this->db->get();
     $thingOptions = array();
     foreach ($query->result() as $row) {
         $thingOptions[] = Thing::loadFromRow($row);
     }
     //get options
     $options = array();
     foreach ($thingOptions as $thingOptions) {
         $options[] = Option::load($thingOptions);
     }
     return $options;
 }
コード例 #7
0
ファイル: event.php プロジェクト: nexgenta/weaver
 public function verify()
 {
     $model = self::$models[get_class($this)];
     if (true !== ($r = parent::verify())) {
         return $r;
     }
     if (isset($this->notionalDate)) {
         if (isset($this->date)) {
             $this->notionalDate = $this->date;
         } else {
             return "Events must at least have a notional date";
         }
     }
     $this->transformProperty('factor', 'factors', true);
     $this->transformProperty('agent', 'agents', true);
     $this->transformProperty('place', 'places', true);
     if (isset($this->factors)) {
         foreach ($this->factors as $k => $factor) {
             if (null === ($obj = $model->locateObject($factor, null, 'thing', $this->universe))) {
                 return 'Factor "' . $factor . '" does not exist yet';
             }
             $this->factors[$k] = $obj->uuid;
         }
     }
     if (isset($this->agents)) {
         foreach ($this->agents as $k => $character) {
             if (null === ($obj = $model->locateObject($character, null, 'character', $this->universe))) {
                 return 'Agent "' . $character . '" does not exist yet';
             }
             $this->agents[$k] = $obj->uuid;
         }
     }
     if (isset($this->places)) {
         foreach ($this->places as $k => $place) {
             if (null === ($obj = $model->locateObject($place, null, 'place', $this->universe))) {
                 return 'Place "' . $place . '" does not exist yet';
             }
             $this->places[$k] = $obj->uuid;
         }
     }
     return true;
 }
コード例 #8
0
ファイル: Ticket.php プロジェクト: deltasystems/teamwork-desk
 public function create($data = [])
 {
     $this->setPath('/tickets.json');
     $this->data = $this->handleDefaults($data, $this->data);
     parent::create();
 }
コード例 #9
0
ファイル: Organization.php プロジェクト: Torann/json-ld
 /**
  * Organization constructor. Merges extendedStructure up
  *
  * @param array $attributes
  * @param array $extendedStructure
  */
 public function __construct(array $attributes, array $extendedStructure = [])
 {
     parent::__construct($attributes, array_merge($this->structure, $this->extendedStructure, $extendedStructure));
 }
コード例 #10
0
 protected function syncChildren($thingName, $member, $parent)
 {
     if (!isset($parent[$member])) {
         throw new DumbassDeveloperException($member . " is not a child member of given parent");
     }
     $channel = Channel::Shopify;
     $children = $parent[$member];
     $parentThing = Thing::loadByAltId($parent["id"]);
     foreach ($children as $child) {
         $id = $child['id'];
         $thingChild = null;
         try {
             $thingChild = Thing::loadByAltId($id);
         } catch (InstanceNotFoundException $ex) {
             //create a thing for the top level product
             $thingChild = new Thing();
             $thingChild->setAltid($id);
             $thingChild->setName($thingName);
             $thingChild->setChannel($channel);
             $thingChild->setThing($parentThing);
             //set the parent of the child thing
             $thingChild->save();
         }
         //all data associated to the child
         $thingData_raw = $thingChild->getData();
         //indexed numerically
         //make array indexed by key
         $thingDatas = array();
         //indexed by key
         foreach ($thingData_raw as $thingData) {
             $thingDatas[$thingData->getKey()] = $thingData;
         }
         foreach ($child as $key => $value) {
             //create a new data if not exist in thingData
             if (!isset($thingDatas[$key])) {
                 $data = new Data();
                 $data->setKey($key);
                 $data->setValue($value);
                 $data->setThing($thingChild);
                 $data->save();
             } else {
                 $dbData = $thingDatas[$key];
                 if ($dbData->getValue() != $value) {
                     $dbData->setValue($value);
                     $dbData->save();
                 }
             }
         }
     }
 }
コード例 #11
0
ファイル: story.php プロジェクト: nexgenta/weaver
 public function verify()
 {
     $this->transformProperty('event', 'events', true);
     return parent::verify();
 }
コード例 #12
0
ファイル: thing.php プロジェクト: rajtrivedi2001/shopify_app
 public function getChildThings($thingName)
 {
     $this->db->select();
     $this->db->from('thing');
     $this->db->where('name', $thingName);
     $this->db->where('thing_id', $this->getId());
     $query = $this->db->get();
     $children = array();
     foreach ($query->result() as $row) {
         $children[] = Thing::loadFromRow($row);
     }
     return $children;
 }
コード例 #13
0
ファイル: Action.php プロジェクト: asiviero/forkwars
 private function formatThing(Thing $thing)
 {
     return array('reference' => 't:' . $thing->getReference(), 'x' => $thing->getPosition()->x, 'y' => $thing->getPosition()->y, 'code' => $thing->getName());
 }
コード例 #14
0
 public function testMissingGetById()
 {
     $t = Thing::Q()->getById("12213213023aa")->exec();
     $this->assertEquals(null, $t);
 }
コード例 #15
0
<?php

trait A { public function bar() { return 1; } }

class Thing {
  use A { A::foo insteadof A; }
}

$t = new Thing;
var_dump($t->foo());
コード例 #16
0
ファイル: import.php プロジェクト: nexgenta/weaver
 protected function importFile($pathname)
 {
     $info = pathinfo($pathname);
     $base = basename($pathname);
     $class = null;
     if (!isset($info['extension'])) {
         $info['extension'] = null;
     }
     switch ($info['extension']) {
         case 'xml':
             require_once dirname(__FILE__) . '/import-xml.php';
             $class = 'WeaverImportXML';
             break;
         case 'json':
             require_once dirname(__FILE__) . '/import-json.php';
             $class = 'WeaverImportJSON';
             break;
         default:
             echo $base . ": Error: Unsupported file type\n";
             return false;
     }
     if (!strlen($class) || !class_exists($class)) {
         echo $base . ": Error: Unable to import (internal error -- class {$class} does not exist)\n";
         return false;
     }
     $inst = new $class();
     $data = $inst->importFile($pathname);
     if (!$data) {
         echo $base . ": Error: Unable to import: import class failed\n";
         return false;
     }
     if (!($thing = Thing::objectForData($data))) {
         echo $base . ": Error: Unable to import: could not create asset object\n";
         return false;
     }
     if (true !== ($r = $thing->verify())) {
         echo $base . ": Error: Unable to import: " . $r . "\n";
         return false;
     }
     if (!isset($thing->kind)) {
         $asset->kind = null;
     }
     if (!isset($thing->uuid) && isset($thing->curie)) {
         if (isset($thing->curie)) {
             if (null !== ($uuid = $this->model->uuidForCurie($asset->curie))) {
                 echo $base . ": Note: Matched CURIE [" . $asset->curie . "] to existing UUID " . $uuid . "\n";
                 $asset->uuid = $uuid;
             }
         }
     }
     if (!isset($thing->uuid) && $thing->kind == 'universe' && strlen($thing->slug)) {
         if ($obj = $this->model->locateObject($thing->slug, null, $thing->kind)) {
             $thing->uuid = $obj->uuid;
         }
     }
     if (!isset($thing->uuid) && $thing->kind != 'universe' && !isset($thing->universe)) {
         echo $base . ": Refusing to import a " . $thing->kind . " which does not have an associated universe.\n";
         return 1;
     }
     if (!isset($thing->uuid) && !isset($thing->slug)) {
         echo $base . ": Refusing to import a " . $thing->kind . " with no slug.\n";
         return 1;
     }
     if (!isset($thing->uuid)) {
         if (null !== ($obj = $this->model->locateObject($thing->slug, isset($thing->parent) ? $thing->parent : null, $thing->kind, $thing->universe))) {
             $thing->uuid = $obj->uuid;
         }
     }
     if (isset($thing->uuid)) {
         /* Check to see whether asset already exists with that UUID,
          * and if so whether it's the same kind.
          */
         if ($old = $this->model->dataForUuid($thing->uuid)) {
             if (!isset($old['kind'])) {
                 $old['kind'] = null;
             }
             if (strcmp($thing->kind, $old['kind'])) {
                 echo $base . ": Warning: Updating thing " . $thing->uuid . " from being a '" . $old['kind'] . "' to being a '" . $thing->kind . "'\n";
             } else {
                 echo $base . ": Updating " . $thing->uuid . "\n";
             }
         }
     }
     if (isset($thing->uuid)) {
         $created = false;
     } else {
         $created = true;
     }
     $thing->store();
     if ($created) {
         echo $base . ": Created with UUID " . $thing->uuid . "\n";
     }
     return true;
 }
コード例 #17
0
ファイル: self_resolution.php プロジェクト: lsqtongxin/hhvm
<?php

trait Stuff
{
    function checkSelf()
    {
        var_dump($this instanceof self);
    }
    function checkParent()
    {
        var_dump($this instanceof parent);
    }
}
class Thing
{
    use Stuff;
}
class SubThing extends Thing
{
    use Stuff;
}
$a = new Thing();
$a->checkSelf();
$b = new SubThing();
$b->checkSelf();
$b->checkParent();
コード例 #18
0
ファイル: RayTracer.php プロジェクト: edin/raytracer
 public function addLight(Color $col, Light $light, Vector $pos, Scene $scene, Thing $thing, Vector $reflectDir, Vector $norm)
 {
     $ldis = Vector::minus($light->pos, $pos);
     $livec = Vector::norm($ldis);
     $neatIsect = $this->testRay(new Ray($pos, $livec), $scene);
     $isInShadow = $neatIsect != null && $neatIsect <= Vector::mag($ldis);
     if ($isInShadow) {
         return $col;
     }
     $illum = Vector::dot($livec, $norm);
     $lcolor = Color::$defaultColor;
     if ($illum > 0) {
         $lcolor = Color::scale($illum, $light->color);
     }
     $specular = Vector::dot($livec, Vector::norm($reflectDir));
     $scolor = Color::$defaultColor;
     $surface = $thing->surface();
     if ($specular > 0) {
         $scolor = Color::scale(pow($specular, $surface->roughness()), $light->color);
     }
     return Color::plus($col, Color::plus(Color::times($surface->diffuse($pos), $lcolor), Color::times($surface->specular($pos), $scolor)));
 }
コード例 #19
0
ファイル: inheritance.php プロジェクト: zhenpanda/toybox_php
class Thing
{
    // public to all
    public $wee = 11;
    // protected to this class and inherted class
    protected $dee = 22;
    // private only for this class
    private $pee = 33;
    function showP()
    {
        echo $this->wee;
        echo "<br>";
        echo $this->pee;
    }
}
$a = new Thing();
echo $a->showP();
echo "<br>";
class Majege extends Thing
{
    function showR()
    {
        echo $this->dee;
        echo "<br>";
    }
}
$b = new Majege();
echo $b->showR();
// static variable
class Box
{