Ejemplo n.º 1
1
 public function get_fields()
 {
     if (is_null($this->fields)) {
         $this->fields = $this->build_fields();
     }
     return $this->fields;
 }
Ejemplo n.º 2
1
 public function __construct(\SimpleXMLElement $xml = null)
 {
     parent::__construct($xml);
     if (is_null($xml)) {
         return;
     }
 }
Ejemplo n.º 3
1
 public function format_time($timestamp, $date_only = false, $date_format = null, $time_format = null, $time_only = false, $no_text = false)
 {
     global $forum_date_formats, $forum_time_formats;
     if ($timestamp == '') {
         return __('Never');
     }
     $diff = ($this->feather->user->timezone + $this->feather->user->dst) * 3600;
     $timestamp += $diff;
     $now = time();
     if (is_null($date_format)) {
         $date_format = $forum_date_formats[$this->feather->user->date_format];
     }
     if (is_null($time_format)) {
         $time_format = $forum_time_formats[$this->feather->user->time_format];
     }
     $date = gmdate($date_format, $timestamp);
     $today = gmdate($date_format, $now + $diff);
     $yesterday = gmdate($date_format, $now + $diff - 86400);
     if (!$no_text) {
         if ($date == $today) {
             $date = __('Today');
         } elseif ($date == $yesterday) {
             $date = __('Yesterday');
         }
     }
     if ($date_only) {
         return $date;
     } elseif ($time_only) {
         return gmdate($time_format, $timestamp);
     } else {
         return $date . ' ' . gmdate($time_format, $timestamp);
     }
 }
Ejemplo n.º 4
1
 /**
  * @return array $routeParameters
  */
 protected function getRouteParameters() : array
 {
     if (is_null(self::$routeParameters)) {
         self::$routeParameters = $this->getController()->getRouteParameters();
     }
     return self::$routeParameters;
 }
Ejemplo n.º 5
1
 /**
  * Format the string response, default is to just return the string.
  *
  * @param  $value
  * @param  $format
  *
  * @return formatted string
  */
 public static function string($value, $format = null)
 {
     if (is_null($format)) {
         $format = '%s';
     }
     return sprintf($format, $value);
 }
Ejemplo n.º 6
1
 /**
  * Main WP_Currencies instance.
  *
  * Ensures only one instance of WP_Currencies is loaded.
  *
  * @since 1.4.0
  *
  * @return WP_Currencies
  */
 public static function get_instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 7
1
 /**
  * Return a textual error message for a Doctrine error code
  *
  * @param   int|array   integer error code,
  *                           null to get the current error code-message map,
  *                           or an array with a new error code-message map
  *
  * @return  string  error message
  */
 public function errorMessage($value = null)
 {
     if (is_null($value)) {
         return self::$_errorMessages;
     }
     return isset(self::$_errorMessages[$value]) ? self::$_errorMessages[$value] : self::$_errorMessages[Doctrine_Core::ERR];
 }
Ejemplo n.º 8
1
 public function getPath($categoryId, $accountId, $delimiter = ' > ')
 {
     $account = Mage::helper('M2ePro/Component_Ebay')->getCachedObject('Account', $accountId);
     $categories = $account->getChildObject()->getEbayStoreCategories();
     $pathData = array();
     while (true) {
         $currentCategory = NULL;
         foreach ($categories as $category) {
             if ($category['category_id'] == $categoryId) {
                 $currentCategory = $category;
                 break;
             }
         }
         if (is_null($currentCategory)) {
             break;
         }
         $pathData[] = $currentCategory['title'];
         if ($currentCategory['parent_id'] == 0) {
             break;
         }
         $categoryId = $currentCategory['parent_id'];
     }
     array_reverse($pathData);
     return implode($delimiter, $pathData);
 }
 public static function getMage2StoreId($mage1StoreId)
 {
     $id = NULL;
     if (isset($mage1StoreId)) {
         if (is_null($mage1StoreId)) {
             $id = 'NULL';
         } else {
             $cacheId = "store_id2_{$mage1StoreId}";
             $val = Yii::app()->cache->get($cacheId);
             if (!$val) {
                 $store1 = Mage1Store::model()->find("store_id = {$mage1StoreId}");
                 if ($store1) {
                     $store2 = Mage2Store::model()->find("code = '{$store1->code}'");
                     if ($store2) {
                         $id = $store2->store_id;
                     }
                 } else {
                     $id = $mage1StoreId;
                 }
                 //save to cache for later
                 Yii::app()->cache->set($cacheId, $id, 86400);
                 // one day
             } else {
                 $id = $val;
             }
         }
     }
     return $id;
 }
Ejemplo n.º 10
1
 public function testSystemMethodSignature()
 {
     $request = $this->encodeRequest('system.methodSignature', array('system.listMethods'));
     $result = $this->server->setPayload($request)->serve();
     $decoded = $this->decodeResponse($result);
     $decoded = (array) $decoded;
     $this->assertCount(1, $decoded);
     $this->assertEquals('array', $decoded[0]);
     $request = $this->encodeRequest('system.methodSignature', array('system.methodSignature'));
     $result = $this->server->setPayload($request)->serve();
     $decoded = $this->decodeResponse($result);
     $decoded = (array) $decoded;
     $this->assertCount(2, $decoded);
     $this->assertEquals('array', $decoded[0]);
     $this->assertEquals('string', $decoded[1]);
     $method = \Comodojo\RpcServer\RpcMethod::create("test.sum", function ($params) {
         $a = $params->get('a');
         $b = $params->get('b');
         return is_null($a) || is_null($b) ? 42 : intval($a) + intval($b);
     })->setDescription("Sum two integers")->setReturnType('int')->addParameter('int', 'a')->addParameter('int', 'b')->addSignature()->setReturnType('int');
     $result = $this->server->methods()->add($method);
     $request = $this->encodeRequest('system.methodSignature', array('test.sum'));
     $result = $this->server->setPayload($request)->serve();
     $decoded = $this->decodeResponse($result);
     $decoded = (array) $decoded;
     $this->assertCount(2, $decoded);
     $this->assertInternalType('array', $decoded[0]);
     $this->assertInternalType('array', $decoded[1]);
     $this->assertCount(3, $decoded[0]);
     $this->assertCount(1, $decoded[1]);
 }
Ejemplo n.º 11
1
 public static function getInstance($dbSetting = 'default')
 {
     if (is_null(static::$instance)) {
         static::$instance = new static($dbSetting);
     }
     return static::$instance;
 }
Ejemplo n.º 12
1
 /**
  * The handler which sets all the values in the dynamic definition.
  *
  * @param String $class the Controller class name
  * @param LaravelSwagger $LS the LaravelSwagger instance.
  * @throws DynamicHandlerException
  */
 public function handle($class, LaravelSwagger $LS)
 {
     /**
      *************************************
      *         Default Behaviour         *
      *************************************
      *
      * Loops through all of the linked keys
      */
     foreach ($this->method->keys() as $key) {
         /** @var mixed $value the value associated with the specific key */
         $value = ValueContainer::getValue($class, $key);
         if (is_string($value)) {
             //if its a string of a class
             //if it is a model that has been registered.
             if (is_subclass_of($value, Model::class) && $LS->hasModel($value)) {
                 $value = "#/definitions/{$value}";
             }
         }
         //if there is no value then throw an exception
         if (is_null($value)) {
             throw new DynamicHandlerException("{$key} value is NULL");
         }
         $this->method->set($key, $value);
     }
 }
Ejemplo n.º 13
1
 public function __construct($p_id = null)
 {
     if (!is_null($p_id)) {
         $this->m_data['id'] = $p_id;
         $this->fetch();
     }
 }
Ejemplo n.º 14
0
 static function get_instance()
 {
     if (is_null(static::$instance)) {
         static::$instance = new self();
     }
     return static::$instance;
 }
Ejemplo n.º 15
0
 /**
  * @param User $user
  * @return bool
  */
 public function is(User $user = null)
 {
     if (is_null($user)) {
         return false;
     }
     return $this->username == $user->username;
 }
Ejemplo n.º 16
0
 /**
  * @param  null       $limit
  * @return Collection
  */
 public function getAll($limit = null)
 {
     if (is_null($limit)) {
         return $this->answer->all();
     }
     return $this->answer->paginate();
 }
Ejemplo n.º 17
0
 private function _checkCountry()
 {
     //$onepage = $this->getOnepage();
     $quote = $this->getOnepage()->getQuote();
     $shipping = $quote->getShippingAddress();
     $billing = $quote->getBillingAddress();
     $default_country = false;
     $country_id = $shipping->getCountryId();
     $helper = Mage::helper('onestepcheckout/checkout');
     $enableGeoIp = Mage::getStoreConfig('onestepcheckout/general/enable_geoip');
     if ($enableGeoIp == 1) {
         if (!$helper->getGeoIp()->countryCode) {
             $countryId = Mage::getStoreConfig('onestepcheckout/general/default_country_id');
         } else {
             $countryId = $helper->getGeoIp()->countryCode;
         }
     } else {
         $countryId = Mage::getStoreConfig('onestepcheckout/general/default_country_id');
     }
     if (is_null($countryId)) {
         $countryId = Mage::helper('core')->getDefaultCountry();
     }
     $shipping->setCountryId($countryId)->setCollectShippingRates(true)->save();
     $billing->setCountryId($countryId)->save();
     $shipping->setSameAsBilling(true)->save();
 }
Ejemplo n.º 18
0
 /**
  * Construct new instance of ResourceAssociationType.
  * 
  * @param string                     $name          Name of the association
  * @param string                     $namespaceName NamespaceName of the 
  *                                                  association
  * @param ResourceAssociationTypeEnd $end1          First end of the association
  * @param ResourceAssociationTypeEnd $end2          Second end of the association
  */
 public function __construct($name, $namespaceName, ResourceAssociationTypeEnd $end1, ResourceAssociationTypeEnd $end2)
 {
     $this->_name = $name;
     $this->_fullName = !is_null($namespaceName) ? $namespaceName . '.' . $name : $name;
     $this->_end1 = $end1;
     $this->_end2 = $end2;
 }
Ejemplo n.º 19
0
 function load($tpl_view, $body_view = null, $data = null)
 {
     if (!is_null($body_view)) {
         if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view)) {
             $body_view_path = $tpl_view . '/' . $body_view;
         } else {
             if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view . '.php')) {
                 $body_view_path = $tpl_view . '/' . $body_view . '.php';
             } else {
                 if (file_exists(APPPATH . 'views/' . $body_view)) {
                     $body_view_path = $body_view;
                 } else {
                     if (file_exists(APPPATH . 'views/' . $body_view . '.php')) {
                         $body_view_path = $body_view . '.php';
                     } else {
                         show_error('Unable to load the requested file: ' . $tpl_name . '/' . $view_name . '.php');
                     }
                 }
             }
         }
         $body = $this->ci->load->view($body_view_path, $data, TRUE);
         if (is_null($data)) {
             $data = array('body' => $body);
         } else {
             if (is_array($data)) {
                 $data['body'] = $body;
             } else {
                 if (is_object($data)) {
                     $data->body = $body;
                 }
             }
         }
     }
     $this->ci->load->view('templates/' . $tpl_view, $data);
 }
Ejemplo n.º 20
0
 public function beforeSave($object)
 {
     $defaultShipping = $object->getDefaultShipping();
     if (is_null($defaultShipping)) {
         $object->unsetDefaultShipping();
     }
 }
Ejemplo n.º 21
0
 /**
  * Embeds a github gist
  *
  * @param string $url Gist url: i.e. https://gist.github.com/2924148
  * @param string $file The name of a particular file from the gist, which should displayed only.
  * @return string
  */
 public static function gist($url, $file = null)
 {
     // url for the script file
     $url = $url . '.js' . r(!is_null($file), '?file=' . $file);
     // load the gist
     return html::tag('script', '', array('src' => $url));
 }
Ejemplo n.º 22
0
    /**
     * Initializes an empty package object
     *
     * @param null|string $definition optional package definition xml
     * @return Mage_Connect_Package
     */
    protected function _init($definition = null)
    {
        if (!is_null($definition)) {
            $this->_packageXml = simplexml_load_string($definition);
        } else {
            $packageXmlStub = <<<END
<?xml version="1.0"?>
<package>
    <name />
    <version />
    <stability />
    <license />
    <channel />
    <extends />
    <summary />
    <description />
    <notes />
    <authors />
    <date />
    <time />
    <replace />
    <compatible />
    <dependencies />
</package>
END;
            $this->_packageXml = simplexml_load_string($packageXmlStub);
        }
        return $this;
    }
 /**
  * (non-PHPdoc).
  *
  * @see \Symfony\Component\Form\DataTransformerInterface::transform()
  */
 public function transform($category)
 {
     if (is_null($category)) {
         return '';
     }
     return $category;
 }
 public function setPassword($value)
 {
     if (is_null($value) || $value === "") {
         $this->addToModelState('Password cannot be null');
     }
     $this->_password = $value;
 }
 /**
  * Retrieve all options array
  *
  * @return array
  */
 public function getAllOptions()
 {
     if (is_null($this->_options)) {
         $this->_options = array(array("label" => Mage::helper("eav")->__("no_select"), "value" => 0), array("label" => Mage::helper("eav")->__("adult_content"), "value" => 1), array("label" => Mage::helper("eav")->__("coupon"), "value" => 2), array("label" => Mage::helper("eav")->__("default"), "value" => 3), array("label" => Mage::helper("eav")->__("electronic_good"), "value" => 4), array("label" => Mage::helper("eav")->__("electronic_software"), "value" => 5), array("label" => Mage::helper("eav")->__("gift_certificate"), "value" => 6), array("label" => Mage::helper("eav")->__("handling_only"), "value" => 7), array("label" => Mage::helper("eav")->__("service"), "value" => 8), array("label" => Mage::helper("eav")->__("shipping_and_handling"), "value" => 9), array("label" => Mage::helper("eav")->__("shipping_only"), "value" => 10), array("label" => Mage::helper("eav")->__("subscription"), "value" => 11));
     }
     return $this->_options;
 }
Ejemplo n.º 26
0
 function encode($src = null, $dest = null)
 {
     if (is_string($src)) {
         if (is_null($dest)) {
             if (!($src = fopen($src, 'r'))) {
                 return false;
             }
             while (!feof($src)) {
                 echo base64_encode(fread($src, 3 * 1024));
             }
             fclose($src);
             return true;
         } else {
             if (is_a($dest, 'Utils_OutputWriter')) {
                 if (!($src = fopen($src, 'r'))) {
                     return false;
                 }
                 while (!feof($src)) {
                     $dest->write(base64_encode(fread($src, 3 * 1024)));
                 }
                 fclose($src);
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 27
0
function show_login()
{
    $error_login_empty_password = null;
    $error_login_empty_user = null;
    $input_user = '';
    $input_password = '';
    if (!empty($_POST)) {
        if (empty($_POST['user'])) {
            $error_login_empty_user = "******";
        } else {
            $input_user = htmlspecialchars($_POST['user']);
        }
        if (empty($_POST['password'])) {
            $error_login_empty_password = "******";
        } else {
            $input_password = htmlspecialchars($_POST['password']);
        }
        if (is_null($error_login_empty_password) && is_null($error_login_empty_user)) {
            header('Location: ?mode=gallery');
            exit(0);
        }
        include_once 'view/head.html';
        include 'view/login.html';
        include_once 'view/foot.html';
    } else {
        include_once 'view/head.html';
        include 'view/login.html';
        include_once 'view/foot.html';
    }
}
 private function getToken()
 {
     if (is_null($this->token)) {
         $this->token = BasicSecurityToken::createFromValues('john.doe', 'john.doe', 'app', 'domain', 'appUrl', '1');
     }
     return $this->token;
 }
Ejemplo n.º 29
0
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $wp;
     // Check cart class is loaded or abort
     if (is_null(WC()->cart)) {
         return;
     }
     // Backwards compat with old pay and thanks link arguments
     if (isset($_GET['order']) && isset($_GET['key'])) {
         _deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.1', '"order" is no longer used to pass an order ID. Use the order-pay or order-received endpoint instead.');
         // Get the order to work out what we are showing
         $order_id = absint($_GET['order']);
         $order = wc_get_order($order_id);
         if ($order->has_status('pending')) {
             $wp->query_vars['order-pay'] = absint($_GET['order']);
         } else {
             $wp->query_vars['order-received'] = absint($_GET['order']);
         }
     }
     // Handle checkout actions
     if (!empty($wp->query_vars['order-pay'])) {
         self::order_pay($wp->query_vars['order-pay']);
     } elseif (isset($wp->query_vars['order-received'])) {
         self::order_received($wp->query_vars['order-received']);
     } else {
         self::checkout();
     }
 }
Ejemplo n.º 30
0
 public function getHash()
 {
     if (is_null($this->hash)) {
         $this->setHash(Util_Secure::generateKey($this->toArray()));
     }
     return $this->hash;
 }