Example #1
4
/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
Example #2
4
 /**
  * @param mixed $in
  */
 public function __construct($in = null)
 {
     $fields = array('to', 'cc', 'bcc', 'message', 'body', 'subject');
     if (is_string($in)) {
         if (($pos = strpos($in, '?')) !== false) {
             parse_str(substr($in, $pos + 1), $this->args);
             $this->args['to'] = substr($in, 0, $pos);
         } else {
             $this->args['to'] = $in;
         }
     } elseif ($in instanceof Horde_Variables) {
         foreach ($fields as $val) {
             if (isset($in->{$val})) {
                 $this->args[$val] = $in->{$val};
             }
         }
     } elseif (is_array($in)) {
         $this->args = $in;
     }
     if (isset($this->args['to']) && strpos($this->args['to'], 'mailto:') === 0) {
         $mailto = @parse_url($this->args['to']);
         if (is_array($mailto)) {
             $this->args['to'] = isset($mailto['path']) ? $mailto['path'] : '';
             if (!empty($mailto['query'])) {
                 parse_str($mailto['query'], $vals);
                 foreach ($fields as $val) {
                     if (isset($vals[$val])) {
                         $this->args[$val] = $vals[$val];
                     }
                 }
             }
         }
     }
 }
Example #3
3
 public function partial($partial, $__time = false, $params = null, $group = 'kumbia.partials')
 {
     //        if (PRODUCTION && $__time && !Cache::driver()->start($__time, $partial, $group)) {
     //            return;
     //        }
     //Verificando el partials en el dir app
     $__file = $this->viewPath . "/_shared/partials/{$partial}.phtml";
     //        if (!is_file($__file)) {
     //            //Verificando el partials en el dir core
     //            $__file = CORE_PATH . "views/partials/$partial.phtml";
     //        }
     if ($params) {
         if (is_string($params)) {
             $params = Util::getParams(explode(',', $params));
         }
         // carga los parametros en el scope
         extract($params, EXTR_OVERWRITE);
     }
     // carga la vista parcial
     if (!(include $__file)) {
         throw new \Exception('Vista Parcial "' . $__file . '" no se encontro');
     }
     // se guarda en la cache de ser requerido
     //        if (PRODUCTION && $__time) {
     //            Cache::driver()->end();
     //        }
 }
Example #4
1
 public function get_headline()
 {
     //$cache = get_cache_function( $this->steam_user->get_id() );
     $headline = array();
     if (PLATFORM_ID == "bid") {
         $user_url = PATH_URL . "home/";
     } else {
         $user_url = PATH_URL . "profile/";
     }
     $user_name = h($this->steam_user->get_name());
     $headline[] = array("name" => h($this->steam_user->get_full_name()), "link" => $user_url);
     if (is_string($context = $this->get_context())) {
         switch ($context) {
             case "profile":
                 $headline[] = array("name" => gettext("Profile"), "link" => "");
                 break;
             case "documents":
                 $headline[] = array("name" => gettext("Documents"), "link" => "");
                 break;
             case "communication":
                 $headline[] = array("name" => gettext("Communication"), "link" => "");
                 break;
             case "groups":
                 $headline[] = array("name" => gettext("Groups"), "link" => "");
                 break;
             case "contacts":
                 $headline[] = array("name" => gettext("Contacts"), "link" => "");
                 break;
         }
     }
     return $headline;
 }
 /**
  * Retrieve filter array
  *
  * @param Enterprise_Search_Model_Resource_Collection $collection
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param string|array $value
  * @return array
  */
 protected function _getSearchParam($collection, $attribute, $value)
 {
     if (!is_string($value) && empty($value) || is_string($value) && strlen(trim($value)) == 0 || is_array($value) && isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
         return array();
     }
     if (!is_array($value)) {
         $value = array($value);
     }
     $field = Mage::getResourceSingleton('enterprise_search/engine')->getSearchEngineFieldName($attribute, 'nav');
     if ($attribute->getBackendType() == 'datetime') {
         $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
         foreach ($value as &$val) {
             if (!is_empty_date($val)) {
                 $date = new Zend_Date($val, $format);
                 $val = $date->toString(Zend_Date::ISO_8601) . 'Z';
             }
         }
         unset($val);
     }
     if (empty($value)) {
         return array();
     } else {
         return array($field => $value);
     }
 }
 /**
  * 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);
     }
 }
Example #7
1
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $settings array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
 public function init($settings = array())
 {
     if (!class_exists('Memcache')) {
         return false;
     }
     if (!isset($settings['prefix'])) {
         $settings['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     $settings += array('engine' => 'Memcache', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true);
     parent::init($settings);
     if ($this->settings['compress']) {
         $this->settings['compress'] = MEMCACHE_COMPRESSED;
     }
     if (is_string($this->settings['servers'])) {
         $this->settings['servers'] = array($this->settings['servers']);
     }
     if (!isset($this->_Memcache)) {
         $return = false;
         $this->_Memcache = new Memcache();
         foreach ($this->settings['servers'] as $server) {
             list($host, $port) = $this->_parseServerString($server);
             if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) {
                 $return = true;
             }
         }
         return $return;
     }
     return true;
 }
 protected function initColumns()
 {
     if (empty($this->columns)) {
         if ($this->dataProvider instanceof CActiveDataProvider) {
             $this->columns = $this->dataProvider->model->attributeNames();
         } elseif ($this->dataProvider instanceof IDataProvider) {
             $data = $this->dataProvider->getData();
             if (isset($data[0]) && is_array($data[0])) {
                 $this->columns = array_keys($data[0]);
             }
         }
     }
     foreach ($this->columns as $i => $column) {
         if (is_string($column)) {
             $this->_columns[] = $column;
         } elseif (is_array($column)) {
             if ($column['header']) {
                 $this->_columns[] = $column['header'];
             } else {
                 $this->_columns[] = $column['name'];
             }
             if ($this->dataProvider instanceof CActiveDataProvider) {
                 if (!$this->_columns[$i]) {
                     $this->_columns[$i] = $this->dataProvider->model->getAttributeLabel($column['name']);
                 }
                 $this->_select[] = $column['name'];
             }
         }
     }
 }
Example #9
0
 public function e($var)
 {
     if (!is_string($var)) {
         throw new Exception('$var must be a string.');
     }
     return htmlspecialchars($var, ENT_QUOTES);
 }
Example #10
0
 /**
  * @param mixed            $value
  * @param AbstractPlatform $platform
  *
  * @return string
  * @throws \InvalidArgumentException
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return '';
     }
     if ($value instanceof \stdClass) {
         $value = get_object_vars($value);
     }
     if (!is_array($value)) {
         throw new \InvalidArgumentException("Hstore value must be off array or \\stdClass.");
     }
     $hstoreString = '';
     foreach ($value as $k => $v) {
         if (!is_string($v) && !is_numeric($v) && !is_bool($v)) {
             throw new \InvalidArgumentException("Cannot save 'nested arrays' into hstore.");
         }
         $v = trim($v);
         if (!is_numeric($v) && false !== strpos($v, ' ')) {
             $v = sprintf('"%s"', $v);
         }
         $hstoreString .= "{$k} => {$v}," . "\n";
     }
     $hstoreString = substr(trim($hstoreString), 0, -1) . "\n";
     return $hstoreString;
 }
Example #11
0
 public static function formatMessage(Rule $rule, $withValue = TRUE)
 {
     $message = $rule->message;
     if ($message instanceof Nette\Utils\Html) {
         return $message;
     } elseif ($message === NULL && is_string($rule->validator) && isset(static::$messages[$rule->validator])) {
         $message = static::$messages[$rule->validator];
     } elseif ($message == NULL) {
         // intentionally ==
         trigger_error("Missing validation message for control '{$rule->control->getName()}'.", E_USER_WARNING);
     }
     if ($translator = $rule->control->getForm()->getTranslator()) {
         $message = $translator->translate($message, is_int($rule->arg) ? $rule->arg : NULL);
     }
     $message = preg_replace_callback('#%(name|label|value|\\d+\\$[ds]|[ds])#', function ($m) use($rule, $withValue) {
         static $i = -1;
         switch ($m[1]) {
             case 'name':
                 return $rule->control->getName();
             case 'label':
                 return $rule->control->translate($rule->control->caption);
             case 'value':
                 return $withValue ? $rule->control->getValue() : $m[0];
             default:
                 $args = is_array($rule->arg) ? $rule->arg : array($rule->arg);
                 $i = (int) $m[1] ? $m[1] - 1 : $i + 1;
                 return isset($args[$i]) ? $args[$i] instanceof IControl ? $withValue ? $args[$i]->getValue() : "%{$i}" : $args[$i] : '';
         }
     }, $message);
     return $message;
 }
Example #12
0
function PMA_gpc_extract($array, &$target, $sanitize = TRUE)
{
    if (!is_array($array)) {
        return FALSE;
    }
    $is_magic_quotes = get_magic_quotes_gpc();
    foreach ($array as $key => $value) {
        /**
         * 2005-02-22, rabus:
         *
         * This is just an ugly hotfix to avoid changing internal config
         * parameters.
         *
         * Currently, the following variable names are rejected when found in
         * $_GET or $_POST: cfg, GLOBALS, str* and _*
         */
        if ($sanitize && is_string($key) && ($key == 'cfg' || $key == 'GLOBALS' || substr($key, 0, 3) == 'str' || $key[0] == '_')) {
            continue;
        }
        if (is_array($value)) {
            // there could be a variable coming from a cookie of
            // another application, with the same name as this array
            unset($target[$key]);
            PMA_gpc_extract($value, $target[$key], FALSE);
        } else {
            if ($is_magic_quotes) {
                $target[$key] = stripslashes($value);
            } else {
                $target[$key] = $value;
            }
        }
    }
    return TRUE;
}
Example #13
0
 public function __construct($a = '')
 {
     parent::__construct();
     $this->a = $a;
     /* parse the before and after graphs if necessary*/
     foreach (array('before', 'after', 'before_rdfxml', 'after_rdfxml') as $rdf) {
         if (!empty($a[$rdf])) {
             if (is_string($a[$rdf])) {
                 /** @var \ARC2_RDFParser $parser */
                 $parser = \ARC2::getRDFParser();
                 $parser->parse(false, $a[$rdf]);
                 $a[$rdf] = $parser->getSimpleIndex(0);
             } else {
                 if (is_array($a[$rdf]) and isset($a[$rdf][0]) and isset($a[$rdf][0]['s'])) {
                     //triples array
                     /** @var \ARC2_RDFSerializer $ser */
                     $ser = \ARC2::getTurtleSerializer();
                     /** @var string $turtle */
                     $turtle = $ser->getSerializedTriples($a[$rdf]);
                     /** @var \ARC2_RDFParser $parser */
                     $parser = \ARC2::getTurtleParser();
                     $parser->parse(false, $turtle);
                     $a[$rdf] = $parser->getSimpleIndex(0);
                 }
             }
             $nrdf = str_replace('_rdfxml', '', $rdf);
             $this->{$nrdf} = $a[$rdf];
         }
     }
     $this->__init();
 }
 /**
  * Creates a Redisent interface to a cluster of Redis servers
  * @param array $servers The Redis servers in the cluster. Each server should be in the format array('host' => hostname, 'port' => port)
  */
 function __construct($servers)
 {
     $this->ring = array();
     $this->aliases = array();
     foreach ($servers as $alias => $server) {
         $this->redisents[] = new Redisent($server['host'], $server['port']);
         if (is_string($alias)) {
             // 用key作为alias标记redis实例
             $this->aliases[$alias] = $this->redisents[count($this->redisents) - 1];
         }
         for ($replica = 1; $replica <= $this->replicas; $replica++) {
             // crc32 — 计算一个字符串的 crc32 多项式,生成 str 的 32 位循环冗余校验码多项式。这通常用于检查传输的数据是否完整。返回值为int类型。
             $this->ring[crc32($server['host'] . ':' . $server['port'] . '-' . $replica)] = $this->redisents[count($this->redisents) - 1];
         }
     }
     // ksort — 对数组按照键名排序
     // 排序类型标记:
     // SORT_REGULAR - 正常比较单元(不改变类型)
     // SORT_NUMERIC - 单元被作为数字来比较
     // SORT_STRING - 单元被作为字符串来比较
     // SORT_LOCALE_STRING - 根据当前的区域(locale)设置来把单元当作字符串比较,可以用 setlocale() 来改变。
     // SORT_NATURAL - 和 natsort() 类似对每个单元以“自然的顺序”对字符串进行排序。 PHP 5.4.0 中新增的。
     // SORT_FLAG_CASE - 能够与 SORT_STRING 或 SORT_NATURAL 合并(OR 位运算),不区分大小写排序字符串。
     ksort($this->ring, SORT_NUMERIC);
     // 将redis实例集合的索引放到$this->nodes中
     $this->nodes = array_keys($this->ring);
 }
Example #15
0
 /**
  * Constructor
  *
  * @param  string|array|Zend_Config $spec Element name or configuration
  * @param  string|array|Zend_Config $options Element value or configuration
  * @return void
  */
 public function __construct($spec, $options = null)
 {
     if (is_string($spec) && (null !== $options && is_string($options))) {
         $options = array('label' => $options);
     }
     parent::__construct($spec, $options);
 }
Example #16
0
 /**
  * Returns an instance of KeyInfo object based on the input KeyInfo XML block
  *
  * @param string $xmlData The KeyInfo XML Block
  * @return Zend_InfoCard_Xml_KeyInfo_Abstract
  * @throws Zend_InfoCard_Xml_Exception
  */
 public static function getInstance($xmlData)
 {
     if ($xmlData instanceof Zend_InfoCard_Xml_Element) {
         $strXmlData = $xmlData->asXML();
     } else {
         if (is_string($xmlData)) {
             $strXmlData = $xmlData;
         } else {
             throw new Zend_InfoCard_Xml_Exception("Invalid Data provided to create instance");
         }
     }
     $sxe = simplexml_load_string($strXmlData);
     $namespaces = $sxe->getDocNameSpaces();
     if (!empty($namespaces)) {
         foreach ($sxe->getDocNameSpaces() as $namespace) {
             switch ($namespace) {
                 case 'http://www.w3.org/2000/09/xmldsig#':
                     include_once 'Zend/InfoCard/Xml/KeyInfo/XmlDSig.php';
                     return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_KeyInfo_XmlDSig');
                 default:
                     throw new Zend_InfoCard_Xml_Exception("Unknown KeyInfo Namespace provided");
                     // We are ignoring these lines, as XDebug reports each as a "non executed" line
                     // which breaks my coverage %
                     // @codeCoverageIgnoreStart
             }
         }
     }
     // @codeCoverageIgnoreEnd
     include_once 'Zend/InfoCard/Xml/KeyInfo/Default.php';
     return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_KeyInfo_Default');
 }
Example #17
0
 public function entries()
 {
     $collection = $this->param("collection", null);
     $entries = [];
     if ($collection) {
         $col = "collection" . $collection["_id"];
         $options = [];
         if ($collection["sortfield"] && $collection["sortorder"]) {
             $options["sort"] = [];
             $options["sort"][$collection["sortfield"]] = $collection["sortorder"];
         }
         if ($filter = $this->param("filter", null)) {
             $options["filter"] = is_string($filter) ? json_decode($filter, true) : $filter;
         }
         if ($limit = $this->param("limit", null)) {
             $options["limit"] = $limit;
         }
         if ($sort = $this->param("sort", null)) {
             $options["sort"] = $sort;
         }
         if ($skip = $this->param("skip", null)) {
             $options["skip"] = $skip;
         }
         $entries = $this->app->db->find("collections/{$col}", $options);
     }
     return json_encode($entries->toArray());
 }
Example #18
0
                 throw new ParamValidationException('Provided param is not a list of permissions, 
                      should be: OBJ1_ACTION1_LANG;OBJ2_ACTION2_LANG;etc');
             }
         }
     }
     return $perms;
 }
Example #19
0
 protected function _finish($code, $originalRedirectUri)
 {
     // This endpoint requires "Basic" auth.
     $clientCredentials = $this->appInfo->getKey() . ":" . $this->appInfo->getSecret();
     $authHeaderValue = "Basic " . base64_encode($clientCredentials);
     $response = RequestUtil::doPostWithSpecificAuth($this->clientIdentifier, $authHeaderValue, $this->userLocale, $this->appInfo->getHost()->getApi(), "1/oauth2/token", array("grant_type" => "authorization_code", "code" => $code, "redirect_uri" => $originalRedirectUri));
     if ($response->statusCode !== 200) {
         throw RequestUtil::unexpectedStatus($response);
     }
     $parts = RequestUtil::parseResponseJson($response->body);
     if (!array_key_exists('token_type', $parts) or !is_string($parts['token_type'])) {
         throw new Exception_BadResponse("Missing \"token_type\" field.");
     }
     $tokenType = $parts['token_type'];
     if (!array_key_exists('access_token', $parts) or !is_string($parts['access_token'])) {
         throw new Exception_BadResponse("Missing \"access_token\" field.");
     }
     $accessToken = $parts['access_token'];
     if (!array_key_exists('uid', $parts) or !is_string($parts['uid'])) {
         throw new Exception_BadResponse("Missing \"uid\" string field.");
     }
     $userId = $parts['uid'];
     if ($tokenType !== "Bearer" && $tokenType !== "bearer") {
         throw new Exception_BadResponse("Unknown \"token_type\"; expecting \"Bearer\", got  " . Client::q($tokenType));
     }
     return array($accessToken, $userId);
 }
 /**
  * @return FileReader
  */
 function stream()
 {
     if (is_string($this->stream)) {
         $this->stream = new FileReader($this->stream);
     }
     return $this->stream;
 }
 /**
  * {@inheritdoc}
  */
 public function collect()
 {
     $request = $this->request;
     $response = $this->response;
     $responseHeaders = $response->headers->all();
     $cookies = array();
     foreach ($response->headers->getCookies() as $cookie) {
         $cookies[] = $this->getCookieHeader($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
     }
     if (count($cookies) > 0) {
         $responseHeaders['Set-Cookie'] = $cookies;
     }
     $statusCode = $response->getStatusCode();
     $data = array('format' => $request->getRequestFormat(), 'content_type' => $response->headers->get('Content-Type') ? $response->headers->get('Content-Type') : 'text/html', 'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '', 'status_code' => $statusCode, 'request_query' => $request->query->all(), 'request_request' => $request->request->all(), 'request_headers' => $request->headers->all(), 'request_server' => $request->server->all(), 'request_cookies' => $request->cookies->all(), 'response_headers' => $responseHeaders, 'path_info' => $request->getPathInfo());
     if ($this->session) {
         $sessionAttributes = array();
         foreach ($this->session->all() as $key => $value) {
             $sessionAttributes[$key] = $value;
         }
         $data['session_attributes'] = $sessionAttributes;
     }
     if (isset($data['request_headers']['php-auth-pw'])) {
         $data['request_headers']['php-auth-pw'] = '******';
     }
     if (isset($data['request_server']['PHP_AUTH_PW'])) {
         $data['request_server']['PHP_AUTH_PW'] = '******';
     }
     foreach ($data as $key => $var) {
         if (!is_string($data[$key])) {
             $data[$key] = $this->formatVar($var);
         }
     }
     return $data;
 }
Example #22
0
 protected function _authenticateValidateResult($resultIdentity)
 {
     $hash = new Application_Plugin_Phpass();
     $check = false;
     // auto-login
     if ($this->_credentialTreatment == 'autologin') {
         $check = true;
     }
     // again, try with md5
     if (is_string($this->_credential) && md5($this->_credential) == $resultIdentity['password']) {
         $check = true;
     }
     // Check that hash value is correct
     if (is_string($this->_credential) && $hash->CheckPassword($this->_credential, $resultIdentity['password'])) {
         $check = true;
     }
     if (!$check) {
         $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
         $this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
         return $this->_authenticateCreateAuthResult();
     }
     $this->_resultRow = $resultIdentity;
     $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;
     $this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
     return $this->_authenticateCreateAuthResult();
 }
Example #23
0
 public static function Column($name, $type, $label = NULL)
 {
     if (is_string($type)) {
         $type = Type::create($type);
     }
     return new Column($name, $type, $label);
 }
Example #24
0
 /**
  * Get all available icons list
  * @param array $img_ext - possible extensions of files in scanned directory
  * @param array $skip - files to skip
  * @return array
  */
 public function get($img_ext = array('gif'), array $skip = array('unknown.gif', 'recycle.bin.empty.gif', 'recycle.bin.full.gif'))
 {
     if (is_string($img_ext)) {
         $img_ext = [$img_ext];
     } elseif (!is_array($img_ext)) {
         dump('Supply a list of possible extensions for icons.');
     }
     if (isset(self::$data[$this->dir])) {
         $data = self::$data[$this->dir];
     } else {
         $data = [];
         $img_ext = array_flip($img_ext);
         foreach (array_diff(scandir($this->dir), ['.', '..']) as $f) {
             $exts = explode('.', $f);
             if (!isset($img_ext[array_pop($exts)])) {
                 continue;
             }
             foreach ($exts as $v) {
                 $data[$v] = $f;
             }
         }
         self::$data[$this->dir] = $data;
     }
     return $skip ? array_diff($data, $skip) : $data;
 }
Example #25
0
 /**
  * Generates and checks presenter class name.
  * @param  string  presenter name
  * @return string  class name
  * @throws InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $class = $this->formatPresenterClass($name);
     if (!class_exists($class)) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' was not found.");
     }
     $reflection = new \ReflectionClass($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     } elseif ($reflection->isAbstract()) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     $this->cache[$name] = $class;
     if ($name !== ($realName = $this->unformatPresenterClass($class))) {
         trigger_error("Case mismatch on presenter name '{$name}', correct name is '{$realName}'.", E_USER_WARNING);
         $name = $realName;
     }
     return $class;
 }
 /**
  * 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');
 }
Example #27
0
 /**
  * createResource()
  *
  * @param Zend_Tool_Project_Profile $profile
  * @param string $actionName
  * @param string $controllerName
  * @param string $moduleName
  * @return Zend_Tool_Project_Profile_Resource
  */
 public static function createResource(Zend_Tool_Project_Profile $profile, $actionName, $controllerName, $moduleName = null)
 {
     if (!is_string($actionName)) {
         //require_once 'Zend/Tool/Project/Provider/Exception.php';
         throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createResource() expects \\"actionName\\" is the name of a controller resource to create.');
     }
     if (!is_string($controllerName)) {
         //require_once 'Zend/Tool/Project/Provider/Exception.php';
         throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createResource() expects \\"controllerName\\" is the name of a controller resource to create.');
     }
     $profileSearchParams = array();
     if ($moduleName) {
         $profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
         $noModuleSearch = null;
     } else {
         $noModuleSearch = array('modulesDirectory');
     }
     $profileSearchParams[] = 'viewsDirectory';
     $profileSearchParams[] = 'viewScriptsDirectory';
     if (($viewScriptsDirectory = $profile->search($profileSearchParams, $noModuleSearch)) === false) {
         //require_once 'Zend/Tool/Project/Provider/Exception.php';
         throw new Zend_Tool_Project_Provider_Exception('This project does not have a viewScriptsDirectory resource.');
     }
     $profileSearchParams['viewControllerScriptsDirectory'] = array('forControllerName' => $controllerName);
     // @todo check if below is failing b/c of above search params
     if (($viewControllerScriptsDirectory = $viewScriptsDirectory->search($profileSearchParams)) === false) {
         $viewControllerScriptsDirectory = $viewScriptsDirectory->createResource('viewControllerScriptsDirectory', array('forControllerName' => $controllerName));
     }
     $newViewScriptFile = $viewControllerScriptsDirectory->createResource('ViewScriptFile', array('forActionName' => $actionName));
     return $newViewScriptFile;
 }
Example #28
0
 /**
  * Create mapper source.
  *
  * @param string|SourceTypeInterface $type
  * @param SourceDataFactoryInterface $dataFactory
  * @param string $name
  *
  * @return Source
  */
 public function create($type, SourceDataFactoryInterface $dataFactory, $name)
 {
     if (is_string($type)) {
         $type = $this->typeRegistry->getType($type);
     }
     return new Source($type, $dataFactory, $name);
 }
Example #29
0
 public function __construct(array $values)
 {
     if (is_string($values['value'])) {
         $values['value'] = array($values['value']);
     }
     $this->roles = $values['value'];
 }
 /**
  * @param string $channel
  *
  * @return Event
  */
 public function setChannel($channel)
 {
     if ((is_string($channel) || is_numeric($channel)) && !empty($channel)) {
         $this->addMetaData('channel', $channel);
     }
     return $this;
 }