コード例 #1
0
ファイル: CSection.php プロジェクト: rootfather/scummvm-web
 public function __construct($data)
 {
     $this->_title = $data['title'];
     $this->_groups = array();
     $this->_subsections = array();
     $this->_paragraphs = array();
     if (isset($data['subsection'])) {
         foreach ($data['subsection'] as $value) {
             $this->_subsections[] = new CSection($value);
         }
     }
     if (isset($data['group'])) {
         parent::toArray($data['group']);
         foreach ($data['group'] as $value) {
             $persons = array();
             if (is_string($value['person'])) {
                 var_dump($value);
                 die;
             }
             parent::toArray($value['person']);
             foreach ($value['person'] as $args) {
                 $persons[] = new Person($args);
             }
             if (count($persons) > 0) {
                 $this->_groups[] = array('name' => $value['name'], 'persons' => $persons);
             }
         }
     }
     if (isset($data['paragraph'])) {
         parent::toArray($data['paragraph']);
         $this->_paragraphs = $data['paragraph'];
     }
 }
コード例 #2
0
ファイル: Dialog.php プロジェクト: jlaso/telegram-cli-wrapper
 /**
  * Transform an stdClass Object returned by history into a HistoryItem
  * @param $item
  */
 public function __construct($item)
 {
     parent::__construct($item);
     $this->flags = new Flags($item->flags);
     $this->from = new User($item->from);
     $this->to = new User($item->to);
 }
コード例 #3
0
ファイル: Screenshot.php プロジェクト: rootfather/scummvm-web
 public function __construct($data)
 {
     $this->_name = $data['name'];
     $this->_category = $data['category'];
     $this->_files = array();
     if (isset($data['image'])) {
         if (!isset($data['image'][0])) {
             parent::toArray($data['image']);
         }
         foreach ($data['image'] as $value) {
             if (isset($value['range'])) {
                 $attr = $value['range']['@attributes'];
                 if (!isset($attr['from']) || !isset($attr['to']) || !isset($attr['format']) || !strstr($value['file'], '#n#')) {
                     throw new ErrorException('Invalid range format for ' . $value['file']);
                 }
                 $pat = str_replace("#n#", $attr['format'], $value['file']);
                 for ($num = $attr['from']; $num <= $attr['to']; $num++) {
                     $this->_files[] = array('filename' => sprintf($pat, $num), 'caption' => $value['caption']);
                 }
             } else {
                 $this->_files[] = array('filename' => $value['file'], 'caption' => $value['caption']);
             }
         }
     }
 }
コード例 #4
0
 public function __set($key, $value)
 {
     if ($value === '') {
         throw new Exception("Missing value for {$key}");
     }
     return parent::__set($key, $value);
 }
 public function __set($key, $value)
 {
     switch ($key) {
         case 'account_id':
             if (!is_numeric($value) || $value <= 0) {
                 throw new Exception("Du måste ange ett giltigt konto.");
             }
             break;
     }
     parent::__set($key, $value);
 }
コード例 #6
0
ファイル: DSection.php プロジェクト: bgK/scummvm-web
 public function __construct($data)
 {
     $this->_title = $data['title'];
     $this->_anchor = $data['anchor'];
     $this->_baseurl = $data['baseurl'];
     $this->_subsections = array();
     parent::toArray($data['subsection']);
     foreach ($data['subsection'] as $key => $value) {
         $this->_subsections[] = new DSubSection($value, $this->_baseurl);
     }
 }
コード例 #7
0
ファイル: QASection.php プロジェクト: rootfather/scummvm-web
 /**
  * QASection object constructor.
  *
  * @param array $data list containing all qasection data
  * @param int $section_number used in the TOC
  * @param array $xref reference to xref map
  */
 public function QASection($data, $section_number, &$xref)
 {
     $this->_title = $data['title'];
     $this->_entries = array();
     $this->_toc = array();
     parent::toArray($data['entry']);
     $count = 1;
     foreach ($data['entry'] as $key => $value) {
         $qa = new QAEntry($value, $section_number, $count++, $xref);
         $this->_entries[] = $qa;
         $this->_toc[$qa->getHref()] = $qa->getQuestion();
     }
 }
コード例 #8
0
ファイル: object.class.php プロジェクト: andy-sheng/ebook
 public function __construct($key, $size = '', $last_modified = '', $etag = '')
 {
     parent::__construct();
     if (is_array($key)) {
         $this->init_from_array($key);
         return $this;
     }
     $this->key = $key;
     $this->size = $size;
     $this->etag = $etag;
     $this->last_modified = $last_modified;
     return $this;
 }
コード例 #9
0
ファイル: Feature.php プロジェクト: erkurita/geojson
 /**
  * @inheritdoc
  */
 public function toGeoArray()
 {
     $result = parent::toGeoArray();
     $properties = $this->getProperties();
     if (empty($properties)) {
         $properties = new \stdClass();
     }
     $result['geometry'] = $this->geometryToGeoJson();
     $result['properties'] = $properties;
     $featureId = $this->getFeatureId();
     if (!is_null($featureId)) {
         $result['id'] = $featureId;
     }
     return $result;
 }
コード例 #10
0
 public static function getAllScreenshots()
 {
     $fname = DIR_DATA . '/screenshots.xml';
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $entries = array();
     BasicObject::toArray($a['screenshots']['group']);
     foreach ($a['screenshots']['group'] as $value) {
         BasicObject::toArray($value['game']);
         $games = array();
         foreach ($value['game'] as $data) {
             $games[] = new Screenshot($data);
         }
         $entries[] = array('title' => $value['title'], 'category' => $value['category'], 'games' => $games);
     }
     return $entries;
 }
コード例 #11
0
 public function commit()
 {
     global $db;
     $ac = $db->is_autocommit();
     if ($ac) {
         $db->autocommit(false);
     }
     if (isset($this->_old_price) && $this->_old_price != $this->price) {
         $log = new ProductLog();
         $log->user_id = $_SESSION['login'];
         $log->old_price = $this->_old_price;
         $log->new_price = $this->price;
         $log->product_id = $this->id;
         $log->commit();
     }
     parent::commit();
     if ($ac) {
         $db->commit();
         $db->autocommit(true);
     }
 }
コード例 #12
0
 public static function getAllSubprojects()
 {
     $fname = DIR_DATA . '/subprojects.xml';
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $entries = array();
     BasicObject::toArray($a['subprojects']['project']);
     foreach ($a['subprojects']['project'] as $key => $value) {
         $downloads = array();
         foreach ($value['entries'] as $type => $data) {
             if ($type == 'file') {
                 BasicObject::toArray($data);
                 foreach ($data as $file) {
                     $downloads[] = new File($file);
                 }
             }
         }
         $entries[] = new Project(array('name' => $value['name'], 'info' => $value['info'], 'downloads' => $downloads));
     }
     return $entries;
 }
コード例 #13
0
 public function __construct($data, $baseurl, $baseturl)
 {
     $this->_title = $data['title'];
     $this->_anchor = $data['anchor'];
     $this->_notes = $data['notes'];
     $this->_footer = $data['footer'];
     $this->_files = array();
     $this->_links = array();
     $this->_items = array();
     foreach ($data['entries'] as $type => $item) {
         parent::toArray($item);
         if ($type == 'file') {
             foreach ($item as $file) {
                 $this->_items[] = new File($file, $baseurl, $baseturl);
             }
         } elseif ($type == 'link') {
             foreach ($item as $link) {
                 $this->_items[] = new WebLink($link);
             }
         }
     }
 }
コード例 #14
0
 /**
  * The class constructor
  *
  * Generate the AbstractBasicObject object from an json string, an array or
  * an object.
  * Whatever the input, we try to construct the basic object
  *
  * @param mixed $data Whatever we can use to create the basic object
  */
 public function __construct($data = null)
 {
     // Si on n'est pas dans la classe 'BasicObject', alors on a
     // potentiellement des attributs et des propriétés à ajouter. Ce n'est
     // pas là qu'on tentera de récupérer les données. On appelle donc la
     // méthode parente
     $this->init();
     if (!get_parent_class($this)) {
         parent::__construct($data);
     } else {
         // Création de l'objet à partir des données
         if (!is_null($data)) {
             $this->setFromSomeData($data);
         }
     }
 }
コード例 #15
0
 /**
  * @inheritdoc
  */
 public function toGeoArray()
 {
     $result = parent::toGeoArray();
     $result['features'] = $this->featuresToGeoJson();
     return $result;
 }
コード例 #16
0
 public static function from_code_name($name)
 {
     return parent::from_field('code_name', $name);
 }
コード例 #17
0
 public function to_array()
 {
     $result = parent::to_array();
     $result[self::PART_NUMBER_TAG] = $this->get_part_numer();
     return $result;
 }