Пример #1
0
 /**
  * Get current instance of dispatcher (singleton)
  *
  * @return Dispatcher
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new Dispatcher();
     }
     return self::$instance;
 }
Пример #2
0
 public function &getInstance()
 {
     if (self::$instance === false) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #3
0
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #4
0
 public static function getInstance($url = null)
 {
     if (!isset(self::$instance)) {
         self::$instance = new self($url);
     }
     return self::$instance;
 }
 function ProcessRequest()
 {
     $messenger = Messenger::Instance()->Receive(__FILE__);
     $mObj = new Anggota();
     $arr_kelompok = $mObj->getKelompok();
     $request_data = array();
     $query_string = '';
     $message = $style = $message = NULL;
     if (isset($mObj->_POST['btnSearch'])) {
         $request_data['nama'] = $mObj->_POST['nama'];
         $request_data['kelompok'] = $mObj->_POST['kelompok'];
     } elseif (isset($mObj->_GET['search'])) {
         $request_data['nama'] = Dispatcher::Instance()->Decrypt($mObj->_GET['nama']);
         $request_data['kelompok'] = Dispatcher::Instance()->Decrypt($mObj->_GET['kelompok']);
     } else {
         $request_data['nama'] = '';
         $request_data['kelompok'] = '';
     }
     if (method_exists(Dispatcher::Instance(), 'getQueryString')) {
         # @param array
         $query_string = Dispatcher::instance()->getQueryString($request_data);
     } else {
         $query = array();
         foreach ($request_data as $key => $value) {
             $query[$key] = Dispatcher::Instance()->Encrypt($value);
         }
         $query_string = urldecode(http_build_query($query));
     }
     $offset = 0;
     $limit = 20;
     $page = 0;
     if (isset($_GET['page'])) {
         $page = (string) $_GET['page']->StripHtmlTags()->SqlString()->Raw();
         $offset = ($page - 1) * $limit;
     }
     #paging url
     $url = Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, Dispatcher::Instance()->mSubModule, Dispatcher::Instance()->mAction, Dispatcher::Instance()->mType) . '&search=' . Dispatcher::Instance()->Encrypt(1) . '&' . $query_string;
     $destination_id = "subcontent-element";
     $data_list = $mObj->getDataAnggota($offset, $limit, $request_data);
     $total_data = $mObj->Count();
     #send data to pagging component
     Messenger::Instance()->SendToComponent('paging', 'Paging', 'view', 'html', 'paging_top', array($limit, $total_data, $url, $page, $destination_id), Messenger::CurrentRequest);
     # Combobox
     Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'kelompok', array('kelompok', $arr_kelompok, $request_data['kelompok'], true, 'id="cmb_kelompok"'), Messenger::CurrentRequest);
     $start = $offset + 1;
     if ($messenger) {
         $message = $messenger[0][1];
         $style = $messenger[0][2];
     }
     return compact('request_data', 'query_string', 'start', 'data_list', 'message', 'style');
 }
 /**
  * Modifies the current context and replaces the info related to shop, link, language and currency.
  *
  * We need this when generating the product data for the different shops and languages.
  * The currency will be the first found for the shop, but it defaults to the PS default currency
  * if no shop specific one is found.
  *
  * @param int $id_lang the language ID to add to the new context.
  * @param int $id_shop the shop ID to add to the new context.
  * @return Context the new context.
  */
 protected function makeContext($id_lang, $id_shop)
 {
     if (_PS_VERSION_ >= '1.5') {
         // Reset the shop context to be the current processed shop. This will fix the "friendly url" format of urls
         // generated through the Link class.
         Shop::setContext(Shop::CONTEXT_SHOP, $id_shop);
         // Reset the dispatcher singleton instance so that the url rewrite setting is check on a shop basis when
         // generating product urls. This will fix the issue of incorrectly formatted urls when one shop has the
         // rewrite setting enabled and another does not.
         Dispatcher::$instance = null;
         if (method_exists('ShopUrl', 'resetMainDomainCache')) {
             // Reset the shop url domain cache so that it is re-initialized on a shop basis when generating product
             // image urls. This will fix the issue of the image urls having an incorrect shop base url when the
             // shops are configured to use different domains.
             ShopUrl::resetMainDomainCache();
         }
         foreach (Currency::getCurrenciesByIdShop($id_shop) as $row) {
             if ($row['deleted'] === '0' && $row['active'] === '1') {
                 $currency = new Currency($row['id_currency']);
                 break;
             }
         }
     }
     $context = Context::getContext();
     $context->language = new Language($id_lang);
     $context->shop = new Shop($id_shop);
     $context->link = new Link('http://', 'http://');
     $context->currency = isset($currency) ? $currency : Currency::getDefaultCurrency();
     return $context;
 }
Пример #7
0
 /**
  * Factory instance should be different from the global instance
  *
  * @test
  * @covers Dispatcher::instance
  * @covers Dispatcher::factory
  */
 public function testFactoryReturnsAnIndividualInstance()
 {
     $instance = Dispatcher::instance();
     $factory = Dispatcher::factory();
     $this->assertNotSame($factory, $instance);
 }