public function __call($s_method_name, $arr_arguments)
 {
     if (!method_exists($this, $s_method_name)) {
         // если еще не имлементировали
         $s_match = "";
         $s_method_prefix = '';
         $s_method_base = '';
         $arr_matches = array();
         $bSucc = preg_match("/[A-Z_]/", $s_method_name, $arr_matches);
         if ($bSucc) {
             $s_match = $arr_matches[0];
             $i_match = strpos($s_method_name, $s_match);
             $s_method_prefix = substr($s_method_name, 0, $i_match) . "/";
             $s_method_base = substr($s_method_name, 0, $i_match + ($s_match === "_" ? 1 : 0));
         }
         $s_class_enter = "__" . $s_method_name;
         // метод, общий для всех режимов
         if (!class_exists($s_class_enter)) {
             $s_entermethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . ".lib.php";
             $this->__loadLib($s_entermethod_lib);
             $this->__implement($s_class_enter);
         }
         $s_class_mode = "__" . $s_method_name . "_";
         // метод, выбираемый в зависимости от режима
         if (!class_exists($s_class_mode)) {
             $s_modemethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . "_" . cmsController::getInstance()->getCurrentMode() . ".lib.php";
             $this->__loadLib($s_modemethod_lib);
             $this->__implement($s_class_mode);
         }
     }
     return parent::__call($s_method_name, $arr_arguments);
 }
Exemple #2
1
 public function __get($name)
 {
     $method = 'get' . ucfirst($name);
     if (method_exists($this, $method)) {
         return $this->{$method}();
     }
 }
Exemple #3
1
 /**
  * Sets selected items (by keys).
  * @param  array
  * @return self
  */
 public function setValue($values)
 {
     if (is_scalar($values) || $values === NULL) {
         $values = (array) $values;
     } elseif (!is_array($values)) {
         throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
     }
     $flip = [];
     foreach ($values as $value) {
         if (!is_scalar($value) && !method_exists($value, '__toString')) {
             throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
         }
         $flip[(string) $value] = TRUE;
     }
     $values = array_keys($flip);
     if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) {
         $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) {
             return var_export($s, TRUE);
         }, array_keys($this->items))), 70, '...');
         $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
         throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed set [{$set}] in field '{$this->name}'.");
     }
     $this->value = $values;
     return $this;
 }
Exemple #4
1
 public function load(TemplateReferenceInterface $template)
 {
     if (method_exists($this, $method = 'get' . ucfirst($template->get('name')) . 'Template')) {
         return new StringStorage($this->{$method}());
     }
     return false;
 }
Exemple #5
0
 /**
  * Add middleware to the pipe-line. Please note that middleware's will
  * be called in the order they are added.
  *
  * A middleware CAN implement the Middleware Interface, but MUST be
  * callable. A middleware WILL be called with three parameters:
  * Request, Response and Next.
  *
  * @throws \RuntimeException when adding middleware to the stack to late
  * @param callable $middleware
  */
 public function pipe(callable $middleware)
 {
     // Check if the pipeline is locked
     if ($this->locked) {
         throw new \RuntimeException('Middleware can’t be added once the stack is dequeuing');
     }
     // Inject the dependency injection container
     if (method_exists($middleware, 'setContainer') && $this->container !== null) {
         $middleware->setContainer($this->container);
     }
     // Force serializers to register mime types
     if ($middleware instanceof SerializerMiddleware) {
         $middleware->registerMimeTypes();
     }
     // Add the middleware to the queue
     $this->queue->enqueue($middleware);
     // Check if middleware should be added to the error queue
     if (!$this->errorQueueLocked) {
         $this->errorQueue->enqueue($middleware);
         // Check if we should lock the error queue
         if ($middleware instanceof ErrorMiddleware) {
             $this->errorQueueLocked = true;
         }
     }
 }
 /**
  * validate a string
  *
  * @param mixed $str the value to evaluate as a string
  *
  * @throws \InvalidArgumentException if the submitted data can not be converted to string
  *
  * @return string
  */
 protected function validateString($str)
 {
     if (is_object($str) && method_exists($str, '__toString') || is_string($str)) {
         return trim($str);
     }
     throw new InvalidArgumentException('The data received is not OR can not be converted into a string');
 }
 public function __call($func, $args)
 {
     $connectionObj = $this->connections[$this->defaultConnection];
     if (method_exists($connectionObj, $func)) {
         call_user_func_array([$connectionObj, $func], $args);
     }
 }
Exemple #8
0
 /**
  * Create the links for resources in the resource root
  * @return array the links, name => config
  */
 protected function createLinks()
 {
     $app = \Yii::app();
     /* @var \Restyii\Web\Application $app */
     $controller = $this->getController();
     $module = $controller->getModule();
     if (!$module) {
         $module = $app;
     }
     $controllers = $app->getSchema()->getControllerInstances($module);
     /* @var \Restyii\Controller\Base[]|\CController[] $controllers */
     $links = array('self' => array('title' => $module->name, 'href' => trim($app->getBaseUrl(), '/') . '/'));
     foreach ($controllers as $id => $controller) {
         if ($id === $module->defaultController) {
             continue;
         }
         $links[$id] = array('title' => method_exists($controller, 'classLabel') ? $controller->classLabel(true) : String::pluralize(String::humanize(substr(get_class($controller), 0, -10))), 'href' => $controller->createUrl('search'));
         if (method_exists($controller, 'classDescription')) {
             $links[$id]['description'] = $controller->classDescription();
         }
         if (isset($controller->modelClass)) {
             $links[$id]['profile'] = array($controller->modelClass);
         }
     }
     return $links;
 }
Exemple #9
0
 static function parse($args)
 {
     $method = strtolower(@$args[1]);
     $string = @$args[0];
     if (empty($string)) {
         return false;
     }
     if (!method_exists('kirbytext', $method)) {
         return $string;
     }
     $replace = array('(', ')');
     $string = str_replace($replace, '', $string);
     $attr = array_merge(self::$tags, self::$attr);
     $search = preg_split('!(' . implode('|', $attr) . '):!i', $string, false, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     $result = array();
     $num = 0;
     foreach ($search as $key) {
         if (!isset($search[$num + 1])) {
             break;
         }
         $key = trim($search[$num]);
         $value = trim($search[$num + 1]);
         $result[$key] = $value;
         $num = $num + 2;
     }
     return self::$method($result);
 }
 /**
  * Make a new experiment with given variants
  *
  * @since 0.1.0
  *
  * @param array $variants
  * @param int|string $id Experiment (group) ID
  * @param \MaBandit\MaBandit $bandit MaBandit object
  */
 public function __construct(array $variants, $id, \MaBandit\MaBandit $bandit)
 {
     $this->experiment = $bandit->createExperiment((string) $id, $variants);
     if (method_exists($bandit->getPersistor(), 'save_levers')) {
         $bandit->getPersistor()->batchSave($this->experiment->getLevers(), $id);
     }
 }
Exemple #11
0
	function displayLayout($layout=null, $tpl = null) {
		if ($layout) $this->setLayout ($layout);
		$viewName = ucfirst($this->getName ());
		$layoutName = ucfirst($this->getLayout ());

		KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;

		if (isset($this->common)) {
			if ($this->config->board_offline && ! $this->me->isAdmin ()) {
				// Forum is offline
				$this->common->header = JText::_('COM_KUNENA_FORUM_IS_OFFLINE');
				$this->common->body = $this->config->offline_message;
				$this->common->display('default');
				KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;
				return;
			} elseif ($this->config->regonly && ! $this->me->exists()) {
				// Forum is for registered users only
				$this->common->header = JText::_('COM_KUNENA_LOGIN_NOTIFICATION');
				$this->common->body = JText::_('COM_KUNENA_LOGIN_FORUM');
				$this->common->display('default');
				KUNENA_PROFILER ? $this->profiler->start("display {$viewName}/{$layoutName}") : null;
				return;
			}
		}

		$this->assignRef ( 'state', $this->get ( 'State' ) );
		$layoutFunction = 'display'.$layoutName;
		if (method_exists($this, $layoutFunction)) {
			$contents = $this->$layoutFunction ($tpl);
		} else {
			$contents = $this->display($tpl);
		}
		KUNENA_PROFILER ? $this->profiler->stop("display {$viewName}/{$layoutName}") : null;
		return $contents;
	}
 public function testGenerator()
 {
     /** @var OpsWay\Test2\Solid\I $generator */
     $generator = OpsWay\Test2\Solid\Factory::create('i');
     $generator->generate();
     $this->assertFileExists($file = __DIR__ . '/../../test/I/IGeometric.php');
     include $file;
     $this->assertTrue(interface_exists('IGeometric'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/IAngular.php');
     include $file;
     $this->assertTrue(interface_exists('IAngular'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/ISquarable.php');
     include $file;
     $this->assertTrue(interface_exists('ISquarable'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/Square.php');
     include $file;
     $this->assertTrue(class_exists('Square'));
     $this->assertTrue(in_array('IGeometric', class_implements('Square')));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/Circle.php');
     include $file;
     $this->assertTrue(class_exists('Circle'));
     $this->assertTrue(in_array('IGeometric', class_implements('Circle')));
     $this->assertTrue(method_exists('IGeometric', 'square'));
     $this->assertTrue(method_exists('ISquarable', 'square'));
     $this->assertTrue(method_exists('IAngular', 'countAngles'));
 }
 /**
  * Constructor.
  *
  * @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0
  */
 public function __construct($classLoader)
 {
     $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile');
     if ($this->wasFinder) {
         @trigger_error('The ' . __METHOD__ . ' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
         $this->classLoader = array($classLoader, 'loadClass');
         $this->isFinder = true;
     } else {
         $this->classLoader = $classLoader;
         $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile');
     }
     if (!isset(self::$caseCheck)) {
         $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR);
         $i = strrpos($file, DIRECTORY_SEPARATOR);
         $dir = substr($file, 0, 1 + $i);
         $file = substr($file, 1 + $i);
         $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
         $test = realpath($dir . $test);
         if (false === $test || false === $i) {
             // filesystem is case sensitive
             self::$caseCheck = 0;
         } elseif (substr($test, -strlen($file)) === $file) {
             // filesystem is case insensitive and realpath() normalizes the case of characters
             self::$caseCheck = 1;
         } elseif (false !== stripos(PHP_OS, 'darwin')) {
             // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters
             self::$caseCheck = 2;
         } else {
             // filesystem case checks failed, fallback to disabling them
             self::$caseCheck = 0;
         }
     }
 }
 /**
  * Render captcha
  *
  * @param string $content
  *
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     if (!method_exists($element, 'getCaptcha')) {
         return $content;
     }
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $placement = $this->getPlacement();
     $separator = $this->getSeparator();
     /** @var \Zend_Captcha_Adapter $captcha */
     $captcha = $element->getCaptcha();
     $markup = '<label>' . $captcha->render($view) . '</label>';
     switch ($placement) {
         case 'PREPEND':
             $content = $markup . $separator . $content;
             break;
         case 'APPEND':
         default:
             $content = $content . $separator . $markup;
             break;
     }
     return $content;
 }
 public function processAPI()
 {
     if (method_exists($this, $this->endpoint)) {
         return $this->_response($this->{$this->endpoint}($this->args));
     }
     return $this->_response("No Endpoint: {$this->endpoint}", 404);
 }
Exemple #16
0
 /**
  * All handlers must implement act() to conform to handler API.
  * This is the default implementation of act(), which attempts
  * to call a class member method of $this->act_$action().  Any
  * subclass is welcome to override this default implementation.
  *
  * @param string $action the action that was in the URL rule
  */
 public function act($action)
 {
     if (null === $this->handler_vars) {
         $this->handler_vars = new SuperGlobal(array());
     }
     $this->action = $action;
     $action_method = 'act_' . $action;
     $before_action_method = 'before_' . $action_method;
     $after_action_method = 'after_' . $action_method;
     if (method_exists($this, $action_method)) {
         if (method_exists($this, $before_action_method)) {
             $this->{$before_action_method}();
         }
         /**
          * Plugin action to allow plugins to execute before a certain
          * action is triggered
          *
          * @see ActionHandler::$action
          * @action before_act_{$action}
          */
         Plugins::act($before_action_method, $this);
         $this->{$action_method}();
         /**
          * Plugin action to allow plugins to execute after a certain
          * action is triggered
          *
          * @see ActionHandler::$action
          * @action before_act_{$action}
          */
         Plugins::act($after_action_method);
         if (method_exists($this, $after_action_method)) {
             $this->{$after_action_method}();
         }
     }
 }
Exemple #17
0
 /**
  * Execute API Call
  *
  * @param   string $apiCall    API Call
  * @param   string $method     Http Method
  * @param   array  $parameters API call parameters
  *
  * @return array
  */
 public static function makeApiCall($apiCall, $method = 'GET', $parameters = array())
 {
     self::getHttp();
     $apiEndpoint = NenoSettings::get('api_server_url');
     $licenseCode = NenoSettings::get('license_code');
     $response = null;
     $responseStatus = false;
     if (!empty($apiEndpoint) && !empty($licenseCode)) {
         $method = strtolower($method);
         if (method_exists(self::$httpClient, $method)) {
             if ($method === 'get') {
                 if (!empty($parameters)) {
                     $query = implode('/', $parameters);
                     $apiCall = $apiCall . '/' . $query;
                 }
                 $apiResponse = self::$httpClient->{$method}($apiEndpoint . $apiCall, array('Authorization' => $licenseCode));
             } else {
                 $apiResponse = self::$httpClient->{$method}($apiEndpoint . $apiCall, json_encode($parameters), array('Content-Type' => 'application/json', 'Authorization' => $licenseCode));
             }
             /* @var $apiResponse JHttpResponse */
             $data = $apiResponse->body;
             if ($apiResponse->headers['Content-Type'] === 'application/json') {
                 $data = json_decode($data, true);
             }
             $response = $data;
             if ($apiResponse->code == 200) {
                 $responseStatus = true;
             }
         }
     }
     return array($responseStatus, $response);
 }
Exemple #18
0
 public function success($response)
 {
     $pq = phpQuery::newDocument($response);
     foreach ($this->calls as $k => $r) {
         // check if method exists
         if (!method_exists(get_class($pq), $r['method'])) {
             throw new Exception("Method '{$r['method']}' not implemented in phpQuery, sorry...");
             // execute method
         } else {
             $pq = call_user_func_array(array($pq, $r['method']), $r['arguments']);
         }
     }
     if (!isset($this->options['dataType'])) {
         $this->options['dataType'] = '';
     }
     switch (strtolower($this->options['dataType'])) {
         case 'json':
             if ($pq instanceof PHPQUERYOBJECT) {
                 $results = array();
                 foreach ($pq as $node) {
                     $results[] = pq($node)->htmlOuter();
                 }
                 print phpQuery::toJSON($results);
             } else {
                 print phpQuery::toJSON($pq);
             }
             break;
         default:
             print $pq;
     }
     // output results
 }
Exemple #19
0
 /**
  * Constructor
  * 
  * @param  Adapter $adapter
  * @param  array $data 
  * @return void
  */
 public function __construct($adapter, $data = null)
 {
     if (!$adapter instanceof Zend_Cloud_Infrastructure_Adapter) {
         #require_once 'Zend/Cloud/Infrastructure/Exception.php';
         throw new Zend_Cloud_Infrastructure_Exception("You must pass a Zend_Cloud_Infrastructure_Adapter instance");
     }
     if (is_object($data)) {
         if (method_exists($data, 'toArray')) {
             $data = $data->toArray();
         } elseif ($data instanceof Traversable) {
             $data = iterator_to_array($data);
         }
     }
     if (empty($data) || !is_array($data)) {
         #require_once 'Zend/Cloud/Infrastructure/Exception.php';
         throw new Zend_Cloud_Infrastructure_Exception("You must pass an array of parameters");
     }
     foreach ($this->attributeRequired as $key) {
         if (empty($data[$key])) {
             #require_once 'Zend/Cloud/Infrastructure/Exception.php';
             throw new Zend_Cloud_Infrastructure_Exception(sprintf('The param "%s" is a required param for %s', $key, __CLASS__));
         }
     }
     $this->adapter = $adapter;
     $this->attributes = $data;
 }
Exemple #20
0
 /**
  * @param string $class_name
  */
 protected function getClass($class_name, $subclass_of = 'Cyan\\Framework\\Controller', array $arguments = [], \Closure $newInstance = null)
 {
     $required_traits = ['Cyan\\Framework\\TraitSingleton'];
     $reflection_class = new ReflectionClass($class_name);
     foreach ($required_traits as $required_trait) {
         if (!in_array($required_trait, $reflection_class->getTraitNames())) {
             throw new TraitException(sprintf('%s class must use %s', $class_name, $required_trait));
         }
     }
     if (!is_subclass_of($class_name, $subclass_of)) {
         throw new TraitException(sprintf('%s class must be a instance of %s', $class_name, $subclass_of));
     }
     if (is_callable($newInstance)) {
         $instance = call_user_func_array($newInstance, $arguments);
     } else {
         $instance = !empty($arguments) ? call_user_func_array([$class_name, 'getInstance'], $arguments) : $class_name::getInstance();
     }
     if ($this->hasContainer('application')) {
         if (!$instance->hasContainer('application')) {
             $instance->setContainer('application', $this->getContainer('application'));
         }
         if (!$instance->hasContainer('factory_plugin')) {
             $instance->setContainer('factory_plugin', $this->getContainer('application')->getContainer('factory_plugin'));
         }
     }
     if (is_callable([$instance, 'initialize']) || method_exists($instance, 'initialize')) {
         $instance->initialize();
     }
     return $instance;
 }
Exemple #21
0
 public function get()
 {
     $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit;
     if ($data = $this->db->getby_id($id)) {
         if (!($str = S('dbsource_' . $id))) {
             if ($data['type'] == 1) {
                 // 自定义SQL调用
                 $get_db = Loader::model("get_model");
                 $sql = $data['data'] . (!empty($data['num']) ? " LIMIT {$data['num']}" : '');
                 $str = $get_db->query($sql);
             } else {
                 $filepath = APPS_PATH . $data['application'] . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . $data['application'] . '_tag.php';
                 if (file_exists($filepath)) {
                     $yun_tag = Loader::lib($data['application'] . ':' . $data['application'] . '_tag');
                     if (!method_exists($yun_tag, $data['do'])) {
                         exit;
                     }
                     $sql = string2array($data['data']);
                     $sql['do'] = $data['do'];
                     $sql['limit'] = $data['num'];
                     unset($data['num']);
                     $str = $yun_tag->{$data}['do']($sql);
                 } else {
                     exit;
                 }
             }
             if ($data['cache']) {
                 S('tpl_data/dbsource_' . $id, $str, $data['cache']);
             }
         }
         echo $this->_format($data['id'], $str, $data['dis_type']);
     }
 }
Exemple #22
0
 public static function init()
 {
     do_action('o2_read_api');
     // Need a 'method' of some sort
     if (empty($_GET['method'])) {
         self::die_failure('no_method', __('No method supplied', 'o2'));
     }
     $method = strtolower($_GET['method']);
     // ?since=unixtimestamp only return posts/comments since the specified time
     global $o2_since;
     $o2_since = false;
     if (isset($_REQUEST['since'])) {
         // JS Date.now() sends milliseconds, so just substr to be safe
         // Also, substract two seconds to allow for differences in client and
         // server clocks
         $o2_since = absint(substr($_REQUEST['since'], 0, 10)) - 2;
     }
     // sanity check.  don't allow arbitrarily low since values
     // or we could end up serving all the posts and comments for the blog
     // so, let's lower bound since to 1 day ago
     $min_since = time() - 24 * 60 * 60;
     if ($o2_since < $min_since) {
         $o2_since = $min_since;
     }
     // Only allow whitelisted methods
     if (in_array($method, apply_filters('o2_read_api_methods', array('poll', 'query', 'preview')))) {
         // Handle different methods
         if (method_exists('o2_Read_API', $method)) {
             o2_Read_API::$method();
         } else {
             self::die_success('1');
         }
     }
     self::die_failure('unknown_method', __('Unknown/unsupported method supplied', 'o2'));
 }
Exemple #23
0
 /**
  * Append any supported $content to $parent
  *
  * @param  DOMNode $parent  Node to append to
  * @param  mixed   $content Content to append
  * @return self
  */
 protected function XMLAppend(\DOMNode &$parent = null, $content = null)
 {
     if (is_null($parent)) {
         $parent = $this->root;
     }
     if (is_string($content) or is_numeric($content) or is_object($content) and method_exists($content, '__toString')) {
         $parent->appendChild($this->createTextNode("{$content}"));
     } elseif (is_object($content) and is_subclass_of($content, '\\DOMNode')) {
         $parent->appendChild($content);
     } elseif (is_array($content) or is_object($content) and $content = get_object_vars($content)) {
         array_map(function ($node, $value) use(&$parent) {
             if (is_string($node)) {
                 if (substr($node, 0, 1) === '@') {
                     $parent->setAttribute(substr($node, 1), $value);
                 } else {
                     $node = $parent->appendChild($this->createElement($node));
                     if (is_string($value)) {
                         $this->XMLAppend($node, $this->createTextNode($value));
                     } else {
                         $this->XMLAppend($node, $value);
                     }
                 }
             } else {
                 $this->XMLAppend($parent, $value);
             }
         }, array_keys($content), array_values($content));
     } elseif (is_bool($content)) {
         $parent->appendChild($this->createTextNode($content ? 'true' : 'false'));
     } else {
         throw new \InvalidArgumentException(sprintf('Unable to append unknown content [%s] to %s', get_class($content), get_class($this)));
     }
     return $this;
 }
Exemple #24
0
 /**
  * 配合BuilderView使用
  * 自动加载 application.fields下的字段类型
  */
 static function builder($arr)
 {
     //实例化的beginWidget('CActiveForm')
     $form = $arr['form'];
     //字段名
     $name = $arr['name'];
     $model = $arr['model'];
     $htmlOptions = array('class' => 'form-control');
     //单个字段的详细配置
     $v = $arr['v'];
     //字段类型 对应application.fields下的文件名
     $type = $v['type'];
     $obj = new $type();
     $chtmlField = $obj->type;
     if ($v['widget']) {
         foreach ($v['widget'] as $k => $vo) {
             echo widget($k, $vo);
         }
     }
     if ($type == 'checkbox') {
         $htmlOptions = array('class' => 'checkbox');
     }
     if (!$chtmlField && method_exists($obj, 'action')) {
         return $obj->action($name, $v['model'], $model->{$name});
     }
     if (!$chtmlField) {
         return;
     }
     if (array_key_exists('datas', $v)) {
         $values = $v['datas'];
         $htmlOptions['encode'] = false;
         return $form->{$chtmlField}($model, $name, $values, $htmlOptions);
     }
     return $form->{$chtmlField}($model, $name, $htmlOptions);
 }
Exemple #25
0
 function display($tpl = null)
 {
     $function = $this->getLayout();
     if (method_exists($this, $function)) {
         $this->{$function}();
     }
 }
 protected function renderEnctype(FormView $view)
 {
     if (!method_exists($form = $this->engine->get('form'), 'enctype')) {
         $this->markTestSkipped(sprintf('Deprecated method %s->enctype() is not implemented.', get_class($form)));
     }
     return (string) $form->enctype($view);
 }
Exemple #27
0
 public function execute($action, $arguments)
 {
     if (!method_exists($this, $action)) {
         throw new Exception("Action '{$action}' is not valid!");
     }
     call_user_func(array($this, $action), $arguments);
 }
Exemple #28
0
 static function start()
 {
     // controller\action by default
     $controller_name = 'site';
     $action_name = 'Index';
     $routes = explode('/', $_SERVER['REQUEST_URI']);
     // get controller name
     if (!empty($routes[1])) {
         $controller_name = $routes[1];
     }
     // get action name
     if (!empty($routes[2])) {
         $action_name = $routes[2];
     }
     $controller_name = $controller_name . 'Controller';
     $action_name = 'action' . $action_name;
     $controller_file = $controller_name . '.php';
     $controller_path = "controllers/" . $controller_file;
     if (file_exists($controller_path)) {
     } else {
         Route::ErrorPage404();
     }
     $controller_name = "\\controllers\\" . $controller_name;
     // create object of received controller
     $controller = new $controller_name();
     $action = $action_name;
     if (method_exists($controller, $action)) {
         // run action
         $controller->{$action}();
     } else {
         Route::ErrorPage404();
     }
 }
Exemple #29
0
 public function __construct()
 {
     //funkcja parseUrl() znajduje sie ponizej
     $url = $this->parseUrl();
     //////////////////////
     //testowanie postowany danych
     if (!empty($_POST)) {
         $url[1] = 'post';
     }
     /////////////////////////////
     if (!$url == NULL) {
         if (file_exists('../app/controllers/' . $url[0] . '.php')) {
             $this->controller = $url[0];
             unset($url[0]);
         } else {
             $this->controller = 'error';
             unset($url[0]);
         }
     }
     require_once '../app/controllers/' . $this->controller . '.php';
     $this->controller = new $this->controller();
     if (isset($url[1])) {
         if (method_exists($this->controller, $url[1])) {
             $this->method = $url[1];
             unset($url[1]);
         }
     }
     $this->params = $url ? array_values($url) : [];
     call_user_func_array([$this->controller, $this->method], $this->params);
 }
Exemple #30
0
 public function leaveNode(Node $node)
 {
     if ($node instanceof Node\Stmt\Class_) {
         $this->collect(array($node->extends));
         $this->collect($node->implements);
         $this->foundClasses[] = $node;
     } elseif ($node instanceof Node\Stmt\Interface_) {
         $this->collect($node->extends);
         $this->foundClasses[] = $node;
     } elseif ($node instanceof Node\Stmt\Trait_) {
         $this->foundClasses[] = $node;
     } elseif ($node instanceof Node\Stmt\TraitUse) {
         $this->collect($node->traits);
     } elseif ($node instanceof Node\Stmt\Declare_) {
         $this->hasFoundInvalidStmt = true;
     } elseif ($node instanceof Node\Expr\Include_) {
         $this->hasFoundInvalidStmt = true;
     } elseif ($node instanceof Node\Expr\FuncCall) {
         if (method_exists($node->name, 'toString')) {
             $function = $node->name->toString();
             if (in_array($function, $this->invalidFunctions)) {
                 $this->hasFoundInvalidStmt = true;
             }
         }
     }
 }