Ejemplo n.º 1
1
 function __construct($config = array())
 {
     parent::__construct($config);
     if (array_key_exists('multi', $config)) {
         $this->set_multi($config['multi']);
     }
 }
Ejemplo n.º 2
1
 public function actionEdit($id)
 {
     $this->pageTitle = Yii::t('app', 'Редактирование категории');
     $model = ShopCategories::model()->findByPk($id);
     if (!$model) {
         throw new CHttpException(404, Yii::t('app', 'Категория не найдена'));
     }
     //var_dump($model->url);die;
     // var_dump($model->path);die;
     //var_dump($model->breadcrumbs);
     //die;
     $this->breadcrumbs = array_merge($this->breadcrumbs, array('Редактирование категории "' . $model->title . '"'));
     $possibleParents = $model->getPossibleParents();
     if (!empty($_POST) && array_key_exists('ShopCategories', $_POST)) {
         $this->performAjaxValidation($model);
         $model->attributes = $_POST['ShopCategories'];
         //var_dump($model->attributes);die;
         if ($model->validate()) {
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', 'Категория "' . $model->title . '" успешно отредактирована');
                 Yii::app()->request->redirect($this->createUrl('index'));
             }
         }
     }
     //var_dump($possibleParents);die;
     $this->render('edit', array('model' => $model, 'possibleParents' => $possibleParents));
 }
Ejemplo n.º 3
1
 /**
  * Save Force SSL option to post or page
  *
  * @param int $post_id
  * @return int $post_id
  */
 public function post_save($post_id)
 {
     if (array_key_exists($this->getPlugin()->getSlug(), $_POST)) {
         if (!wp_verify_nonce($_POST[$this->getPlugin()->getSlug()], $this->getPlugin()->getSlug())) {
             return $post_id;
         }
         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
             return $post_id;
         }
         if (@$_POST['post_type'] == 'page') {
             if (!current_user_can('edit_page', $post_id)) {
                 return $post_id;
             }
         } else {
             if (!current_user_can('edit_post', $post_id)) {
                 return $post_id;
             }
         }
         $force_ssl = @$_POST['force_ssl'] == 1 ? true : false;
         if ($force_ssl) {
             update_post_meta($post_id, 'force_ssl', 1);
         } else {
             delete_post_meta($post_id, 'force_ssl');
         }
         $force_ssl_children = @$_POST['force_ssl_children'] == 1 ? true : false;
         if ($force_ssl_children) {
             update_post_meta($post_id, 'force_ssl_children', 1);
         } else {
             delete_post_meta($post_id, 'force_ssl_children');
         }
     }
     return $post_id;
 }
Ejemplo n.º 4
1
 /**
  * {@inheritdoc}
  */
 public function apply(DataSourceInterface $dataSource, $name, $data, array $options)
 {
     $expressionBuilder = $dataSource->getExpressionBuilder();
     if (is_array($data) && !isset($data['type'])) {
         $data['type'] = isset($options['type']) ? $options['type'] : self::TYPE_CONTAINS;
     }
     if (!is_array($data)) {
         $data = ['type' => self::TYPE_CONTAINS, 'value' => $data];
     }
     $fields = array_key_exists('fields', $options) ? $options['fields'] : [$name];
     $type = $data['type'];
     $value = array_key_exists('value', $data) ? $data['value'] : null;
     if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim($value)) {
         return;
     }
     if (1 === count($fields)) {
         $dataSource->restrict($this->getExpression($expressionBuilder, $type, current($fields), $value));
         return;
     }
     $expressions = [];
     foreach ($fields as $field) {
         $expressions[] = $this->getExpression($expressionBuilder, $type, $field, $value);
     }
     $dataSource->restrict($expressionBuilder->orX(...$expressions));
 }
 /**
  * @return array
  */
 public function getCoupon()
 {
     if (!array_key_exists('coupon', $this->request)) {
         return array();
     }
     return $this->request['coupon'];
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f = $this->env->getExtension("native_profiler");
     $__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f->enter($__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "WebProfilerBundle:Profiler:toolbar_item.html.twig"));
     // line 1
     if (isset($context["link"]) ? $context["link"] : $this->getContext($context, "link")) {
         // line 2
         echo "    ";
         ob_start();
         // line 3
         echo "        <a href=\"";
         echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("_profiler", array("token" => isset($context["token"]) ? $context["token"] : $this->getContext($context, "token"), "panel" => isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"))), "html", null, true);
         echo "\">";
         echo twig_escape_filter($this->env, isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "html", null, true);
         echo "</a>\n    ";
         $context["icon"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     }
     // line 6
     echo "<div class=\"sf-toolbar-block\">\n     <div class=\"sf-toolbar-icon\">";
     // line 7
     echo twig_escape_filter($this->env, array_key_exists("icon", $context) ? _twig_default_filter(isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "") : "", "html", null, true);
     echo "</div>\n     <div class=\"sf-toolbar-info\">";
     // line 8
     echo twig_escape_filter($this->env, array_key_exists("text", $context) ? _twig_default_filter(isset($context["text"]) ? $context["text"] : $this->getContext($context, "text"), "") : "", "html", null, true);
     echo "</div>\n</div>\n";
     $__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f->leave($__internal_7088dc18de042b162a99a327c85232e1f7c79938f5c6e62a2f20a47464d52c5f_prof);
 }
 private function has_attribute($attribute)
 {
     // get object_vars return an associative array with all attributes
     $object_vars = get_object_vars($this);
     // will not care the value only whether the key is exists
     return array_key_exists($attribute, $object_vars);
 }
Ejemplo n.º 8
0
 /**
  * Returns class instance.
  *
  * @param string $type the table type
  *
  * @return PMA_RecentFavoriteTable
  */
 public static function getInstance($type)
 {
     if (!array_key_exists($type, self::$_instances)) {
         self::$_instances[$type] = new PMA_RecentFavoriteTable($type);
     }
     return self::$_instances[$type];
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70 = $this->env->getExtension("native_profiler");
     $__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70->enter($__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/toolbar_item.html.twig"));
     // line 1
     if (isset($context["link"]) ? $context["link"] : $this->getContext($context, "link")) {
         // line 2
         echo "    ";
         ob_start();
         // line 3
         echo "        <a href=\"";
         echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("_profiler", array("token" => isset($context["token"]) ? $context["token"] : $this->getContext($context, "token"), "panel" => isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"))), "html", null, true);
         echo "\">";
         echo twig_escape_filter($this->env, isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "html", null, true);
         echo "</a>\n    ";
         $context["icon"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     }
     // line 6
     echo "<div class=\"sf-toolbar-block\">\n     <div class=\"sf-toolbar-icon\">";
     // line 7
     echo twig_escape_filter($this->env, array_key_exists("icon", $context) ? _twig_default_filter(isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "") : "", "html", null, true);
     echo "</div>\n     <div class=\"sf-toolbar-info\">";
     // line 8
     echo twig_escape_filter($this->env, array_key_exists("text", $context) ? _twig_default_filter(isset($context["text"]) ? $context["text"] : $this->getContext($context, "text"), "") : "", "html", null, true);
     echo "</div>\n</div>\n";
     $__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70->leave($__internal_f6fbb0d538f0cf945a7cc2537fcd6ea50556067234df0d59685d58ab6cd80c70_prof);
 }
Ejemplo n.º 10
0
 /**
  * Get an attribute from the container.
  *
  * @param  string $key
  * @param  mixed $default
  *
  * @return mixed
  */
 public function get($key, $default = null)
 {
     if (array_key_exists($key, $this->attributes)) {
         return $this->attributes[$key];
     }
     return Misc::value($default);
 }
Ejemplo n.º 11
0
 /**
  * Returns an array of fields that have failed validation. On the current model. This method will
  * actually run validation rules over data, not just return the messages.
  *
  * @param array $data The data to be checked for errors
  * @param bool $newRecord whether the data to be validated is new or to be updated.
  * @return array Array of invalid fields
  * @see Validator::validates()
  */
 public function errors(array $data, $newRecord = true)
 {
     $errors = [];
     $requiredMessage = __d('cake', 'This field is required');
     $emptyMessage = __d('cake', 'This field cannot be left empty');
     foreach ($this->_fields as $name => $field) {
         $keyPresent = array_key_exists($name, $data);
         if (!$keyPresent && !$this->_checkPresence($field, $newRecord)) {
             $errors[$name][] = isset($this->_presenceMessages[$name]) ? $this->_presenceMessages[$name] : $requiredMessage;
             continue;
         }
         if (!$keyPresent) {
             continue;
         }
         $providers = $this->_providers;
         $context = compact('data', 'newRecord', 'field', 'providers');
         $canBeEmpty = $this->_canBeEmpty($field, $context);
         $isEmpty = $this->_fieldIsEmpty($data[$name]);
         if (!$canBeEmpty && $isEmpty) {
             $errors[$name][] = isset($this->_allowEmptyMessages[$name]) ? $this->_allowEmptyMessages[$name] : $emptyMessage;
             continue;
         }
         if ($isEmpty) {
             continue;
         }
         $result = $this->_processRules($name, $field, $data, $newRecord);
         if ($result) {
             $errors[$name] = $result;
         }
     }
     return $errors;
 }
Ejemplo n.º 12
0
 public function isValid()
 {
     switch ($this->method) {
         case self::METHOD_CREATE_LIST:
             return array_key_exists('LIST_ID', $this->data) && $this->data['LIST_ID'] > 0;
             break;
         case self::METHOD_ADD_SUBSCRIBER:
             return array_key_exists('UID', $this->data);
             break;
         case self::METHOD_GET_SENDERS:
             return true;
             break;
         case self::METHOD_CREATE_CAMPAIGN_EMAIL:
         case self::METHOD_CREATE_CAMPAIGN_SMS:
         case self::METHOD_CREATE_CAMPAIGN_VOICE:
             return array_key_exists('id', $this->data);
             break;
         case self::METHOD_SEND_SMS:
         case self::METHOD_SEND_CALL:
         case self::METHOD_SEND_EMAIL:
             return !array_key_exists('ERROR', $this->data);
             break;
         case self::METHOD_ADD_SUBSCRIBER_BULK:
             return $this->data['RESULT'] == 'OK';
             break;
         default:
             return false;
     }
 }
Ejemplo n.º 13
0
 /**
  * dijit.Editor
  *
  * @param  string $id
  * @param  string $value
  * @param  array $params
  * @param  array $attribs
  * @return string
  */
 public function editor($id, $value = null, $params = array(), $attribs = array())
 {
     if (isset($params['plugins'])) {
         foreach ($this->_getRequiredModules($params['plugins']) as $module) {
             $this->dojo->requireModule($module);
         }
     }
     // Previous versions allowed specifying "degrade" to allow using a
     // textarea instead of a div -- but this is insecure. Removing the
     // parameter if set to prevent its injection in the dijit.
     if (isset($params['degrade'])) {
         unset($params['degrade']);
     }
     $hiddenName = $id;
     if (array_key_exists('id', $attribs)) {
         $hiddenId = $attribs['id'];
     } else {
         $hiddenId = $hiddenName;
     }
     $hiddenId = $this->_normalizeId($hiddenId);
     $textareaName = $this->_normalizeEditorName($hiddenName);
     $textareaId = $hiddenId . '-Editor';
     $hiddenAttribs = array('id' => $hiddenId, 'name' => $hiddenName, 'value' => $value, 'type' => 'hidden');
     $attribs['id'] = $textareaId;
     $this->_createGetParentFormFunction();
     $this->_createEditorOnSubmit($hiddenId, $textareaId);
     $attribs = $this->_prepareDijit($attribs, $params, 'textarea');
     $html = '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();
     $html .= '<div' . $this->_htmlAttribs($attribs) . '>' . $value . "</div>\n";
     // Embed a textarea in a <noscript> tag to allow for graceful
     // degradation
     $html .= '<noscript>' . $this->view->formTextarea($hiddenId, $value, $attribs) . '</noscript>';
     return $html;
 }
Ejemplo n.º 14
0
 /**
  * search user/corporation or alliance by name
  * @param $f3
  * @param $params
  */
 public function search($f3, $params)
 {
     $accessData = [];
     if (array_key_exists('arg1', $params) && array_key_exists('arg2', $params)) {
         $searchType = strtolower($params['arg1']);
         $searchToken = strtolower($params['arg2']);
         $accessModel = null;
         switch ($searchType) {
             case 'user':
                 $accessModel = Model\BasicModel::getNew('UserModel');
                 break;
             case 'corporation':
                 $accessModel = Model\BasicModel::getNew('CorporationModel');
                 break;
             case 'alliance':
                 $accessModel = Model\BasicModel::getNew('AllianceModel');
                 break;
         }
         if (is_object($accessModel)) {
             // find "active" entries that have their "sharing" option activated
             $accessList = $accessModel->find(array("LOWER(name) LIKE :token AND " . "active = 1 AND " . "shared = 1 ", ':token' => '%' . $searchToken . '%'));
             if ($accessList) {
                 foreach ($accessList as $accessObject) {
                     $accessData[] = $accessObject->getData();
                 }
             }
         }
     }
     echo json_encode($accessData);
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76 = $this->env->getExtension("native_profiler");
     $__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76->enter($__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/toolbar_item.html.twig"));
     // line 1
     echo "<div class=\"sf-toolbar-block sf-toolbar-block-";
     echo twig_escape_filter($this->env, isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"), "html", null, true);
     echo " sf-toolbar-status-";
     echo twig_escape_filter($this->env, array_key_exists("status", $context) ? _twig_default_filter(isset($context["status"]) ? $context["status"] : $this->getContext($context, "status"), "normal") : "normal", "html", null, true);
     echo " ";
     echo twig_escape_filter($this->env, array_key_exists("additional_classes", $context) ? _twig_default_filter(isset($context["additional_classes"]) ? $context["additional_classes"] : $this->getContext($context, "additional_classes"), "") : "", "html", null, true);
     echo "\">\n    ";
     // line 2
     if (array_key_exists("link", $context) ? _twig_default_filter(isset($context["link"]) ? $context["link"] : $this->getContext($context, "link"), true) : true) {
         echo "<a href=\"";
         echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("_profiler", array("token" => isset($context["token"]) ? $context["token"] : $this->getContext($context, "token"), "panel" => isset($context["name"]) ? $context["name"] : $this->getContext($context, "name"))), "html", null, true);
         echo "\">";
     }
     // line 3
     echo "        <div class=\"sf-toolbar-icon\">";
     echo twig_escape_filter($this->env, array_key_exists("icon", $context) ? _twig_default_filter(isset($context["icon"]) ? $context["icon"] : $this->getContext($context, "icon"), "") : "", "html", null, true);
     echo "</div>\n    ";
     // line 4
     if (array_key_exists("link", $context) ? _twig_default_filter(isset($context["link"]) ? $context["link"] : $this->getContext($context, "link"), true) : true) {
         echo "</a>";
     }
     // line 5
     echo "        <div class=\"sf-toolbar-info\">";
     echo twig_escape_filter($this->env, array_key_exists("text", $context) ? _twig_default_filter(isset($context["text"]) ? $context["text"] : $this->getContext($context, "text"), "") : "", "html", null, true);
     echo "</div>\n</div>\n";
     $__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76->leave($__internal_820209f0de803f23c5c55988658f5e579064679e98e57a683a7a6b5b5e40ae76_prof);
 }
Ejemplo n.º 16
0
 public static function addBelongsToInformation($model, $key, $display, $data)
 {
     if (isset($model->belongModels) && array_key_exists($key, $model->belongModels)) {
         $belongData = $model->belongModels[$key];
         if (!isset($belongData["showon"]) || static::isValidView($belongData, $display)) {
             if (!isset($belongData["model"])) {
                 throw new Exception("Model Attribute not Found in belongsModels for {$key}", 1);
             }
             if (!isset($belongData["column"])) {
                 throw new Exception("Column Attribute not Found in belongsModels for {$key}", 1);
             }
             $column = $belongData["column"];
             $modelName = ucwords($belongData["model"]);
             $belongModel = $model->belongs_to("Admin\\{$modelName}", $key)->first();
             if (isset($belongModel)) {
                 $data = $belongModel->{$column};
             } else {
                 if (isset($belongData["alternative_text"])) {
                     $data = $belongData["alternative_text"];
                 }
             }
         }
     }
     return $data;
 }
Ejemplo n.º 17
0
 public function add($script, $type = "text/javascript")
 {
     if (!array_key_exists($type, $this->inlinescripts)) {
         $this->inlinescripts[$type] = [];
     }
     $this->inlinescripts[$type][] = $string . "\n";
 }
Ejemplo n.º 18
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);
 }
 private function createStorage($storageKey, array $storages, $urlResolver, Config $config)
 {
     if (!array_key_exists($storageKey, $storages)) {
         throw new InvalidArgumentException("{$storageKey} is not a valid fineuploader server storage");
     }
     $storage = $storages[$storageKey];
     if (!array_key_exists('class', $storage)) {
         throw new InvalidArgumentException("{$storageKey} does not have a valid storage class");
     }
     $storageConfig = array_key_exists('config', $storage) ? $storage['config'] : [];
     if (is_array($urlResolver)) {
         if (!array_key_exists('class', $urlResolver)) {
             throw new InvalidArgumentException("urlResolver needs a class key");
         }
         $resolverConfig = array_key_exists('config', $urlResolver) ? $urlResolver['config'] : [];
         $urlResolver = new $urlResolver['class']($resolverConfig);
         if (!$urlResolver instanceof UrlResolverInterface) {
             throw new InvalidArgumentException(get_class($urlResolver) . " does not implement " . "Optimus\\Http\\UrlResolverInterface");
         }
     } elseif (!is_callable($urlResolver)) {
         throw new InvalidArgumentException("Url resolver is not a method.");
     }
     $storage = new $storage['class']($storageConfig, $config, $urlResolver);
     return $storage;
 }
Ejemplo n.º 20
0
 /**
  * Converts entity labels for entity reference fields to entity ids.
  *
  * @param string $entity_type
  *   The type of the entity being processed.
  * @param string $entity_bundle
  *   The bundle of the entity being processed.
  * @param array $values
  *   An array of field values keyed by field name.
  *
  * @return array
  *   The processed field values.
  *
  * @throws \Exception
  *   Thrown when no entity with the given label has been found.
  */
 public function convertEntityReferencesValues($entity_type, $entity_bundle, $values)
 {
     $definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type, $entity_bundle);
     foreach ($definitions as $name => $definition) {
         if ($definition->getType() != 'entity_reference' || !array_key_exists($name, $values) || !strlen($values[$name])) {
             continue;
         }
         // Retrieve the entity type and bundles that can be referenced.
         $settings = $definition->getSettings();
         $target_entity_type = $settings['target_type'];
         $target_entity_bundles = $settings['handler_settings']['target_bundles'];
         // Multi-value fields are separated by comma.
         $labels = explode(', ', $values[$name]);
         $values[$name] = [];
         foreach ($labels as $label) {
             $id = $this->getEntityIdByLabel($label, $target_entity_type, $target_entity_bundles);
             $bundles = implode(',', $target_entity_bundles);
             if (!$id) {
                 throw new \Exception("Entity with label '{$label}' could not be found for '{$target_entity_type} ({$bundles})' to fill field '{$name}'.");
             }
             $values[$name][] = $id;
         }
     }
     return $values;
 }
Ejemplo n.º 21
0
/**
 * Returns upload status.
 *
 * This is implementation for uploadprogress extension.
 */
function PMA_getUploadStatus($id)
{
    global $SESSION_KEY;
    global $ID_KEY;
    if (trim($id) == "") {
        return;
    }
    if (!array_key_exists($id, $_SESSION[$SESSION_KEY])) {
        $_SESSION[$SESSION_KEY][$id] = array('id' => $id, 'finished' => false, 'percent' => 0, 'total' => 0, 'complete' => 0, 'plugin' => $ID_KEY);
    }
    $ret = $_SESSION[$SESSION_KEY][$id];
    if (!PMA_import_uploadprogressCheck() || $ret['finished']) {
        return $ret;
    }
    $status = uploadprogress_get_info($id);
    if ($status) {
        if ($status['bytes_uploaded'] == $status['bytes_total']) {
            $ret['finished'] = true;
        } else {
            $ret['finished'] = false;
        }
        $ret['total'] = $status['bytes_total'];
        $ret['complete'] = $status['bytes_uploaded'];
        if ($ret['total'] > 0) {
            $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
        }
    } else {
        $ret = array('id' => $id, 'finished' => true, 'percent' => 100, 'total' => $ret['total'], 'complete' => $ret['total'], 'plugin' => $ID_KEY);
    }
    $_SESSION[$SESSION_KEY][$id] = $ret;
    return $ret;
}
Ejemplo n.º 22
0
 protected function getField($_field)
 {
     if (array_key_exists($_field, $this->fieldMap)) {
         return $this->fieldMap[$_field];
     }
     return $_field;
 }
Ejemplo n.º 23
0
 function findPrimaryElement($element, $parsed)
 {
     if (empty($parsed)) {
         return false;
     }
     // If no primary element, return root
     if (!$element) {
         return $parsed;
     }
     if (isset($parsed[$element])) {
         // Ensure we return an array - even if only one element found
         if (is_array($parsed[$element])) {
             if (array_key_exists('0', $parsed[$element])) {
                 // is multidimensional
                 return $parsed[$element];
             } else {
                 return array($parsed[$element]);
             }
         }
     }
     foreach ($parsed as $key => $val) {
         if (is_array($val)) {
             $return = $this->findPrimaryElement($element, $val);
             if ($return !== false) {
                 return $return;
             }
         }
     }
     return false;
 }
Ejemplo n.º 24
0
/**
 * This is the model class for table "dcmd_task_template".
 *
 * @property integer $task_tmpt_id
 * @property string $task_tmpt_name
 * @property integer $task_cmd_id
 * @property string $task_cmd
 * @property integer $svr_id
 * @property string $svr_name
 * @property integer $app_id
 * @property integer $update_env
 * @property integer $concurrent_rate
 * @property integer $timeout
 * @property integer $process
 * @property integer $auto
 * @property string $task_arg
 * @property string $comment
 * @property string $utime
 * @property string $ctime
 * @property integer $opr_uid
 */
function xml_to_array($xml)
{
    //array(1) { ["env"]=> array(2) { ["name"]=> string(2) "gu" ["aa"]=> string(4) "miao" } }
    $reg = "/<(\\w+)[^>]*?>([\\x00-\\xFF]*?)<\\/\\1>/";
    if (preg_match_all($reg, $xml, $matches)) {
        $count = count($matches[0]);
        $arr = array();
        for ($i = 0; $i < $count; $i++) {
            $key = $matches[1][$i];
            $val = xml_to_array($matches[2][$i]);
            // 递归
            if (array_key_exists($key, $arr)) {
                if (is_array($arr[$key])) {
                    if (!array_key_exists(0, $arr[$key])) {
                        $arr[$key] = array($arr[$key]);
                    }
                } else {
                    $arr[$key] = array($arr[$key]);
                }
                $arr[$key][] = $val;
            } else {
                $arr[$key] = $val;
            }
        }
        return $arr;
    } else {
        return $xml;
    }
}
Ejemplo n.º 25
0
 function FindOrk2Player($ork3_id, $aname, $fname, $lname, $chapter)
 {
     if (array_key_exists($chapter, $this->chapterMap)) {
         $sql = "\n                    select * \n                        from ORKplayers\n                        where chapterID = {$this->chapterMap[$chapter]}\n                            and aname like '{$aname}' and fname like '{$fname}' and lname like '{$lname}'";
         $player = $this->ORK2->query($sql);
         if ($player->size() == 1) {
             //echo "Found $ork3_id: ($aname): {$player->playerID}; ";
             $this->iOrk2->RecordTransfer('players', 'Player', $player->playerID, $ork3_id, array(), 1);
             return true;
         } else {
             if ($player->size() > 1) {
                 //echo "Too many...";
             } else {
                 //echo "No hits...";
             }
         }
     }
     $sql = "\n                select * \n                    from ORKplayers\n                    where \n                        aname like '" . mysql_real_escape_string($aname) . "' \n                        and fname like '" . mysql_real_escape_string($fname) . "' \n                        and lname like '" . mysql_real_escape_string($lname) . "'";
     $player = $this->ORK2->query($sql);
     if ($player->size() == 1) {
         //echo "Found $ork3_id: ($aname): {$player->playerID}; ";
         $this->iOrk2->RecordTransfer('players', 'Player', $player->playerID, $ork3_id, array(), 1);
         return true;
     } else {
         if ($player->size() > 1) {
             //echo "Too many...";
         } else {
             //echo "No hits...";
         }
     }
     return false;
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 1
     $this->env->loadTemplate("OpportunityBundle:Default:shareUserModal.html.twig")->display($context);
     // line 2
     echo "<div class=\"panel panel-default\">\n    <div class=\"panel-body\">\n        <div style=\"padding:25px\">\n            <div class=\"row\">\n                <div class=\"col-lg-12\">\n                    <div class=\"pull-right\">  \n                        <span calss=\"pull-right\">\n                            <a href=\"#\" style=\"color: black;\" data-toggle=\"modal\" data-target=\"#myModal\"><i class=\"fa fa-search\"></i> Filters</a>\n                        </span>\n                        ";
     // line 11
     if (!array_key_exists("contactid", $context)) {
         // line 12
         echo "                        <span calss=\"pull-right\" style=\"margin-left: 10px; border-left: 2px solid #ddd;\">\n                            <a href=\"javascript:showHideContacts()\" id=\"showHide\" style=\"color: black;margin-left: 5px;\"><i class=\"fa fa-eye-slash\" id=\"showContacttoggle\"></i></a>\n                        </span>\n                        ";
     }
     // line 16
     echo "                        <span calss=\"pull-right\" style=\"margin-left: 2px;border-right: 2px solid #ddd;border-left: 2px solid #ddd;\">\n                            <a href=\"javascript:refreshTable()\" style=\"color: black;\"><i class=\"fa fa-refresh fa-lg\" style=\"margin-left: 5px;margin-right: 2px;\"></i></a>\n                        </span>\n                        <span calss=\"pull-right\" style=\"margin-left: 10px\">\n                            <a href=\"javascript:window.print()\" style=\"color: black;\"><i class=\"fa fa-print fa-lg\"></i></a>\n                        </span>\n                        ";
     // line 25
     echo "                        <span calss=\"pull-right\" style=\"margin-left: 10px\">\n                            <a href=\"javascript:exportTableDataToCSV()\" style=\"color: black;\"><i class=\"fa fa-file-excel-o fa-lg\"></i></a>\n                        </span>\n                        <span calss=\"pull-right\" style=\"margin-left: 10px\">\n                            <a href=\"javascript:exportTableDataToPDF()\" id='pdfexport' style=\"color: black;\"><i class=\"fa fa-file-pdf-o fa-lg\"></i></a>\n                        </span>\n                        <span calss=\"pull-right\" style=\"margin-left: 10px\">\n                            <a href=\"javascript:resetTable()\" style=\"color: black;\"><i class=\"fa fa-times fa-lg\"></i></a>\n                        </span>\n                    </div>\n                </div>\n            </div>\n\n            ";
     // line 38
     $this->env->loadTemplate("OpportunityBundle:Default:filterModal.html.twig")->display($context);
     // line 39
     echo "            \n            <div class=\"row\">\n                <div class=\"col-lg-12\" id=\"tableDiv\" style=\"display: none\">\n                    <div id=\"user-table-div\" class=\"table-responsive\" style=\"min-height: 360px;padding-bottom: 100px\">\n                        <table id=\"table\"\n                               data-toggle=\"table\"\n                               data-detail-view=\"true\"\n                               data-search=\"true\"\n                               data-page-size=\"";
     // line 47
     echo twig_escape_filter($this->env, isset($context["manageview"]) ? $context["manageview"] : $this->getContext($context, "manageview"), "html", null, true);
     echo "\"\n                               data-page-list=\"[10,25,50]\"\n                               data-pagination=\"true\"\n                               data-show-columns=\"true\"\n                               data-detail-formatter=\"detailFormatter\"\n                               data-row-style=\"rowStyle\">\n                            <thead>\n                                <tr>\n                                    <th data-field=\"state\" data-checkbox=\"true\"></th>\n                                    <th data-field=\"name\" data-sortable=\"true\">Name</th>\n                                    <th data-field=\"company\" data-sortable=\"true\">Company</th>\n                                    <th data-field=\"product_type\" data-sortable=\"true\">Product <br>Type</th>\n                                    <th data-field=\"stage\" data-sortable=\"true\">Stage</th>\n                                    <th data-field=\"weighted_revenue\" data-sortable=\"true\">Weighted<br> Revenue</th>\n                                    <th data-field=\"projected_revenue\" data-sortable=\"true\">Projected<br> Revenue</th>\n                                    <th data-field=\"expected_closed_date\" data-sortable=\"true\">Expected Close<br> Deals</th>\n                                    <th data-field=\"owner\" data-sortable=\"true\">Owner</th>\n                                    <th data-field=\"deal_account_type\" data-sortable=\"true\">account type</th>\n                                    <th data-field=\"deal_source\" data-sortable=\"true\">source</th>\n                                    <th data-field=\"action\">Action</th>\n                                    <th data-field=\"tags\">tags</th>\n                                </tr>\n                            </thead>\n                        </table>\n                    </div>\n                </div>\n            </div>\n        </div>\n\n    </div>\n</div>\n";
     // line 78
     $this->env->loadTemplate("OpportunityBundle:Default:opportunityTableScript.html.twig")->display($context);
 }
Ejemplo n.º 27
0
Archivo: Thead.php Proyecto: itav/table
 public function delElement($index)
 {
     if (array_key_exists($index, $this->elements)) {
         unset($this->elements[$index]);
     }
     return $this;
 }
Ejemplo n.º 28
0
 public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
 {
     if (!array_key_exists($type, self::$fieldNames)) {
         throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
     }
     return self::$fieldNames[$type];
 }
Ejemplo n.º 29
0
 public function init()
 {
     $model = $this->model;
     if (!$this->extra_fields) {
         $this->extra_fields = array();
     }
     if (empty($_POST['id'])) {
         $this->data = $model::model()->findAll(array('order' => 'display_order asc'));
     } else {
         $this->data = array();
         foreach ($_POST['id'] as $i => $id) {
             $item = new $model();
             $item->id = $id;
             $item->name = $_POST['name'][$i];
             $attributes = $item->getAttributes();
             if (array_key_exists('active', $attributes)) {
                 $item->active = isset($_POST['active'][$i]) || intval($id) == 0 ? 1 : 0;
             }
             foreach ($this->extra_fields as $field) {
                 $item->{$field['field']} = $_POST[$field['field']][$i];
             }
             $this->data[] = $item;
         }
     }
     return parent::init();
 }
Ejemplo n.º 30
-2
 /**
  * Class loader method
  *
  * Additional arguments may be supplied and are passed to the sub-class.
  * Additional include paths are also able to be specified for third-party use
  *
  * @param   string  $key  The name of helper method to load, (prefix).(class).function
  *                        prefix and class are optional and can be used to load custom
  *                        html helpers.
  *
  * @return  mixed  JHtml::call($function, $args) or False on error
  *
  * @since   1.5
  * @throws  InvalidArgumentException
  */
 public static function _($key)
 {
     list($key, $prefix, $file, $func) = static::extract($key);
     if (array_key_exists($key, static::$registry)) {
         $function = static::$registry[$key];
         $args = func_get_args();
         // Remove function name from arguments
         array_shift($args);
         return static::call($function, $args);
     }
     $className = $prefix . ucfirst($file);
     if (!class_exists($className)) {
         $path = JPath::find(static::$includePaths, strtolower($file) . '.php');
         if ($path) {
             require_once $path;
             if (!class_exists($className)) {
                 throw new InvalidArgumentException(sprintf('%s not found.', $className), 500);
             }
         } else {
             throw new InvalidArgumentException(sprintf('%s %s not found.', $prefix, $file), 500);
         }
     }
     $toCall = array($className, $func);
     if (is_callable($toCall)) {
         static::register($key, $toCall);
         $args = func_get_args();
         // Remove function name from arguments
         array_shift($args);
         return static::call($toCall, $args);
     } else {
         throw new InvalidArgumentException(sprintf('%s::%s not found.', $className, $func), 500);
     }
 }