コード例 #1
0
 public function listEntities()
 {
     $entitiesCollection = new EntityCollection();
     $orderSense = '';
     $orderKey = '';
     if (isset($_GET['orderSense']) && isset($_GET['orderKey'])) {
         $orderSense = $_GET['orderSense'];
         $orderKey = $_GET['orderKey'];
     }
     $listEntities = $entitiesCollection->all($orderKey, $orderSense);
     echo $this->templater->loadAdminPage('entity-list.php', $listEntities);
 }
コード例 #2
0
 public function entityManager()
 {
     $entityCollection = new EntityCollection();
     // SANITIZE ALL DATA
     if (isset($_POST)) {
         foreach ($_POST as $key => &$value) {
             if (is_array($value)) {
                 // FOR ARRAY OBJECT
                 foreach ($value as $keyItem => &$valueItem) {
                     $valueItem = sanitize_text_field($valueItem);
                 }
             } else {
                 // FOR VALUE
                 $value = sanitize_text_field($value);
             }
         }
     }
     // check http or https
     if (isset($_SERVER['HTTPS'])) {
         $linkToList = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?page=sociallymap-entity-list';
     } else {
         $linkToList = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?page=sociallymap-entity-list';
     }
     // ACTION ENTITY : delete
     if (array_key_exists('sociallymap_deleteEntity', $_POST) && $_POST['sociallymap_deleteEntity']) {
         $_POST['submit'] = esc_html($_POST['submit']);
         $idRemoving = $_POST['submit'];
         $entityCollection->deleteRowsByID($idRemoving);
     }
     // ACTION ENTITY : update
     if (array_key_exists('sociallymap_updateEntity', $_POST) && $_POST['sociallymap_updateEntity']) {
         if (isset($_POST['sociallymap_name']) && empty($_POST['sociallymap_name'])) {
             $isValid = false;
         }
         if (isset($_POST['sociallymap_entityId']) && empty($_POST['sociallymap_entityId'])) {
             $isValid = false;
         }
         if (!isset($_POST['sociallymap_activate'])) {
             $_POST['sociallymap_activate'] = 0;
         }
         if (!isset($_POST['sociallymap_category'])) {
             $_POST['sociallymap_category'] = [];
         } else {
             foreach ($_POST['sociallymap_category'] as $key => &$value) {
                 $value = esc_html($value);
             }
         }
         if (!isset($_POST['sociallymap_display_type'])) {
             $_POST['sociallymap_display_type'] = 'tab';
         }
         if (!isset($_POST['sociallymap_link_canonical'])) {
             $_POST['sociallymap_link_canonical'] = 0;
         }
         if (!isset($_POST['sociallymap_noIndex'])) {
             $_POST['sociallymap_noIndex'] = 0;
         }
         if (!isset($_POST['sociallymap_noFollow'])) {
             $_POST['sociallymap_noFollow'] = 0;
         }
         if (!isset($_POST['sociallymap_morebalise'])) {
             $_POST['sociallymap_morebalise'] = 0;
         }
         if (!isset($_POST['sociallymap_readmore'])) {
             $_POST['sociallymap_readmore'] = '';
         } else {
             $_POST['sociallymap_readmore'] = stripslashes($_POST['sociallymap_readmore']);
         }
         $data = ['name' => esc_html($_POST['sociallymap_label']), 'category' => $_POST['sociallymap_category'], 'activate' => esc_html($_POST['sociallymap_activate']), 'sm_entity_id' => esc_html($_POST['sociallymap_entityId']), 'display_type' => esc_html($_POST['sociallymap_display_type']), 'publish_type' => esc_html($_POST['sociallymap_publish_type']), 'link_canonical' => esc_html($_POST['sociallymap_link_canonical']), 'noIndex' => esc_html($_POST['sociallymap_noIndex']), 'noFollow' => esc_html($_POST['sociallymap_noFollow']), 'image' => esc_html($_POST['sociallymap_image']), 'readmore' => esc_html($_POST['sociallymap_readmore']), 'morebalise' => esc_html($_POST['sociallymap_morebalise']), 'id' => esc_html($_GET['id'])];
         $entityCollection->update($data);
         $this->updatePosts();
         wp_redirect($linkToList, 301);
         exit;
     }
     // ACTION ENTITY : post
     if (array_key_exists('sociallymap_postEntity', $_POST) && $_POST['sociallymap_postEntity']) {
         $isValid = true;
         if (isset($_POST['sociallymap_name']) && empty($_POST['sociallymap_name'])) {
             $isValid = false;
         }
         if (isset($_POST['sociallymap_entityId']) && empty($_POST['sociallymap_entityId'])) {
             $isValid = false;
         }
         if (!isset($_POST['sociallymap_activate'])) {
             $_POST['sociallymap_activate'] = 0;
         }
         if (!isset($_POST['sociallymap_category'])) {
             $_POST['sociallymap_category'] = '';
         } else {
             foreach ($_POST['sociallymap_category'] as $key => &$value) {
                 $value = esc_html($value);
             }
         }
         if (!isset($_POST['sociallymap_display_type'])) {
             $_POST['sociallymap_display_type'] = 'tab';
         }
         if (!isset($_POST['sociallymap_link_canonical'])) {
             $_POST['sociallymap_link_canonical'] = 0;
         }
         if (!isset($_POST['sociallymap_noIndex'])) {
             $_POST['sociallymap_noIndex'] = 0;
         }
         if (!isset($_POST['sociallymap_noFollow'])) {
             $_POST['sociallymap_noFollow'] = 0;
         }
         if (isset($_POST['sociallymap_readmore'])) {
             $_POST['sociallymap_readmore'] = stripslashes($_POST['sociallymap_readmore']);
         } else {
             $_POST['sociallymap_readmore'] = '';
         }
         if (!isset($_POST['sociallymap_morebalise'])) {
             $_POST['sociallymap_morebalise'] = '';
         }
         if ($isValid == false) {
             $_POST['sociallymap_isNotValid'] = true;
             return false;
         }
         $data = ['name' => esc_html($_POST['sociallymap_name']), 'category' => $_POST['sociallymap_category'], 'activate' => esc_html($_POST['sociallymap_activate']), 'sm_entity_id' => esc_html($_POST['sociallymap_entityId']), 'publish_type' => esc_html($_POST['sociallymap_publish_type']), 'display_type' => esc_html($_POST['sociallymap_display_type']), 'link_canonical' => esc_html($_POST['sociallymap_link_canonical']), 'noIndex' => esc_html($_POST['sociallymap_noIndex']), 'noFollow' => esc_html($_POST['sociallymap_noFollow']), 'readmore' => esc_html($_POST['sociallymap_readmore']), 'image' => esc_html($_POST['sociallymap_image']), 'morebalise' => esc_html($_POST['sociallymap_morebalise'])];
         $entityCollection->add($data);
         wp_redirect($linkToList, 301);
         exit;
     }
 }
コード例 #3
0
ファイル: EntityCollection.php プロジェクト: chinazan/zzcrm
 public function merge(EntityCollection $collection)
 {
     $newData = $this->container;
     $incomingData = $collection->getInnerContainer();
     foreach ($incomingData as $v) {
         if (!$this->contains($v)) {
             $this->container[] = $v;
         }
     }
 }
コード例 #4
0
 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Checks if current position is valid
  * @link http://php.net/manual/en/iterator.valid.php
  * @return boolean The return value will be casted to boolean and then evaluated.
  * Returns true on success or false on failure.
  */
 public function valid()
 {
     return $this->collection->offsetExists($this->current);
 }
コード例 #5
0
ファイル: ManagerAbstract.php プロジェクト: thoom/dbm
 /**
  * NYI: Return an EntityCollection of entities filtered by the conditions array sent
  *
  * @param array|string|QueryBuilder $query
  * @param array $params
  * @return bool|EntityCollection
  */
 public function fetchAll($query, array $params = array())
 {
     if (is_array($query)) {
         $query = new QueryBuilder($this->table, $this->db, $query);
     }
     if (count($params) < 1 && $query instanceof QueryBuilder) {
         $params = $query->params();
     }
     $data = $this->db->fetchAll($query, $params);
     if ($data) {
         $collection = new EntityCollection();
         foreach ($data as $item_data) {
             $collection->attach($this->fresh($item_data, false));
         }
         return $collection;
     }
     return false;
 }
コード例 #6
0
ファイル: EntityRepository.php プロジェクト: matak/dbrecord
 public function collection(Query $query)
 {
     $collection = new EntityCollection($this);
     $collection->importQuery($query);
     return $collection;
 }
コード例 #7
0
 public function load()
 {
     if (!$this->fluent) {
         try {
             // pokud neni fluent set, nastav defaultni
             $this->fluent();
         } catch (FluentOnNonExistingParentOfAssociationException $e) {
             $this->setLoadable(false);
             return $this;
         }
     }
     return parent::load();
 }
コード例 #8
0
ファイル: ScraperTest.php プロジェクト: pharman/Test
 public function testScrape()
 {
     $mockOutput = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface');
     $this->object->scrape('test', $mockOutput);
 }