PHP strtolower Examples

PHP strtolower - 30 examples found. These are the top rated real world PHP examples of strtolower extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
1
 /**
  * Add all the routes in the router in parameter
  * @param $router Router
  */
 public function generateRoute(Router $router)
 {
     foreach ($this->classes as $class) {
         $classMethods = get_class_methods($this->namespace . $class . 'Controller');
         $rc = new \ReflectionClass($this->namespace . $class . 'Controller');
         $parent = $rc->getParentClass();
         $parent = get_class_methods($parent->name);
         $className = $this->namespace . $class . 'Controller';
         foreach ($classMethods as $methodName) {
             if (in_array($methodName, $parent) || $methodName == 'index') {
                 continue;
             } else {
                 foreach (Router::getSupportedHttpMethods() as $httpMethod) {
                     if (strstr($methodName, $httpMethod)) {
                         continue 2;
                     }
                     if (in_array($methodName . $httpMethod, $classMethods)) {
                         $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
                         unset($classMethods[$methodName . $httpMethod]);
                     }
                 }
                 $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
             }
         }
         $router->add('/' . strtolower($class), new $className(), 'index');
     }
 }
 /**
  * Return a OpenSeadragon image viewer for the provided files.
  * 
  * @param File|array $files A File record or an array of File records.
  * @param int $width The width of the image viewer in pixels.
  * @param int $height The height of the image viewer in pixels.
  * @return string|null
  */
 public function openseadragon($files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     // Filter out invalid images.
     $images = array();
     $imageNames = array();
     foreach ($files as $file) {
         // A valid image must be a File record.
         if (!$file instanceof File) {
             continue;
         }
         // A valid image must have a supported extension.
         $extension = pathinfo($file->original_filename, PATHINFO_EXTENSION);
         if (!in_array(strtolower($extension), $this->_supportedExtensions)) {
             continue;
         }
         $images[] = $file;
         $imageNames[explode(".", $file->filename)[0]] = openseadragon_dimensions($file, 'original');
     }
     // Return if there are no valid images.
     if (!$images) {
         return;
     }
     return $this->view->partial('common/openseadragon.php', array('images' => $images, 'imageNames' => $imageNames));
 }
 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
Example #4
1
 /**
  * Get link definition defined in 'fields' metadata. In linkDefs can be used as value (e.g. "type": "hasChildren") and/or variables (e.g. "entityName":"{entity}"). Variables should be defined into fieldDefs (in 'entityDefs' metadata).
  *
  * @param  string $entityName
  * @param  array  $fieldDef
  * @param  array  $linkFieldDefsByType
  * @return array | null
  */
 public function getLinkDefsInFieldMeta($entityName, $fieldDef, array $linkFieldDefsByType = null)
 {
     if (!isset($fieldDefsByType)) {
         $fieldDefsByType = $this->getFieldDefsByType($fieldDef);
         if (!isset($fieldDefsByType['linkDefs'])) {
             return null;
         }
         $linkFieldDefsByType = $fieldDefsByType['linkDefs'];
     }
     foreach ($linkFieldDefsByType as $paramName => &$paramValue) {
         if (preg_match('/{(.*?)}/', $paramValue, $matches)) {
             if (in_array($matches[1], array_keys($fieldDef))) {
                 $value = $fieldDef[$matches[1]];
             } else {
                 if (strtolower($matches[1]) == 'entity') {
                     $value = $entityName;
                 }
             }
             if (isset($value)) {
                 $paramValue = str_replace('{' . $matches[1] . '}', $value, $paramValue);
             }
         }
     }
     return $linkFieldDefsByType;
 }
Example #5
1
 function calculateGFRResult()
 {
     $tmpArr = array();
     $tmpArr[] = date('Y-m-d H:i:s');
     //observation time
     $tmpArr[] = 'GFR (CALC)';
     //desc
     $gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender");
     $crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]");
     $genderFactor = null;
     $creaValue = null;
     $personAge = null;
     $raceFactor = 1;
     switch ($gender[key($gender)]) {
         case 'M':
             $genderFactor = 1;
             break;
         case 'F':
             $genderFactor = 0.742;
             break;
     }
     if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') {
         $creaValue = $crea[key($crea)]['value'];
     }
     $person = new Person();
     $person->personId = $this->_patientId;
     $person->populate();
     if ($person->age > 0) {
         $personAge = $person->age;
     }
     $personStat = new PatientStatistics();
     $personStat->personId = $this->_patientId;
     $personStat->populate();
     if ($personStat->race == "AFAM") {
         $raceFactor = 1.21;
     }
     $gfrValue = "INC";
     if ($personAge > 0 && $creaValue > 0) {
         $gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186);
     }
     trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE);
     $tmpArr[] = $gfrValue;
     // lab value
     $tmpArr[] = 'mL/min/1.73 m2';
     //units
     $tmpArr[] = '';
     //ref range
     $tmpArr[] = '';
     //abnormal
     $tmpArr[] = 'F';
     //status
     $tmpArr[] = date('Y-m-d H:i:s') . '::' . '0';
     // observationTime::(boolean)normal; 0 = abnormal, 1 = normal
     $tmpArr[] = '0';
     //sign
     //$this->_calcLabResults[uniqid()] = $tmpArr;
     $this->_calcLabResults[1] = $tmpArr;
     // temporarily set index to one(1) to be able to include in selected lab results
     return $tmpArr;
 }
Example #6
1
 /**
  * @param EveApiReadWriteInterface $data
  * @param EveApiRetrieverInterface $retrievers
  * @param EveApiPreserverInterface $preservers
  * @param int                      $interval
  *
  * @throws LogicException
  */
 public function autoMagic(EveApiReadWriteInterface $data, EveApiRetrieverInterface $retrievers, EveApiPreserverInterface $preservers, $interval)
 {
     $this->getLogger()->debug(sprintf('Starting autoMagic for %1$s/%2$s', $this->getSectionName(), $this->getApiName()));
     /**
      * Update Industry Jobs History
      */
     $class = new IndustryJobsHistory($this->getPdo(), $this->getLogger(), $this->getCsq());
     $class->autoMagic($data, $retrievers, $preservers, $interval);
     $active = $this->getActiveCharacters();
     if (0 === count($active)) {
         $this->getLogger()->info('No active characters found');
         return;
     }
     foreach ($active as $char) {
         $data->setEveApiSectionName(strtolower($this->getSectionName()))->setEveApiName($this->getApiName());
         if ($this->cacheNotExpired($this->getApiName(), $this->getSectionName(), $char['characterID'])) {
             continue;
         }
         $data->setEveApiArguments($char)->setEveApiXml();
         if (!$this->oneShot($data, $retrievers, $preservers, $interval)) {
             continue;
         }
         $this->updateCachedUntil($data->getEveApiXml(), $interval, $char['characterID']);
     }
 }
 public static function prompt_bool_input($question, $default = true, $question_id = 'UNKNOWN')
 {
     // Prompt user for yes/no question
     /*if BATCH MODE
     		{
     			switch($question_id)
     			{
     				default:
     					$auto_answer = 'true';
     					break;
     			}
     
     			$answer = pts_strings::string_bool($auto_answer);
     		}*/
     $question .= ' (' . ($default == true ? 'Y/n' : 'y/N') . '): ';
     do {
         pts_client::$display->generic_prompt($question);
         $input = strtolower(pts_user_io::read_user_input());
     } while ($input != 'y' && $input != 'n' && $input != '');
     switch ($input) {
         case 'y':
             $answer = true;
             break;
         case 'n':
             $answer = false;
             break;
         default:
             $answer = $default;
             break;
     }
     return $answer;
 }
Example #8
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);
 }
Example #9
0
 function db($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = 'utf8', $pconnect = 0)
 {
     if ($pconnect) {
         if (!($this->mlink = @mysql_pconnect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     } else {
         if (!($this->mlink = @mysql_connect($dbhost, $dbuser, $dbpw))) {
             $this->halt('Can not connect to MySQL');
         }
     }
     if ($this->version() > '4.1') {
         if ('utf-8' == strtolower($dbcharset)) {
             $dbcharset = 'utf8';
         }
         if ($dbcharset) {
             mysql_query("SET character_set_connection={$dbcharset}, character_set_results={$dbcharset}, character_set_client=binary", $this->mlink);
         }
         if ($this->version() > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->mlink);
         }
     }
     if ($dbname) {
         mysql_select_db($dbname, $this->mlink);
     }
 }
Example #10
0
	function __construct()
	{
		parent::__construct();
		$this->module=strtolower(get_class());
		$this->load->model('Mtintuc');
		$this->load->library('pagination');
	}
Example #11
0
function loadController($class)
{
    if (file_exists(CONTROLLERS_DIR . DS . strtolower($class) . '.php')) {
        require_once CONTROLLERS_DIR . DS . strtolower($class) . '.php';
    }
    return;
}
Example #12
0
 public function lostpasswordAction()
 {
     $username = $this->_getParam("username");
     if ($username) {
         $user = User::getByName($username);
         if (!$user instanceof User) {
             $this->view->error = "user unknown";
         } else {
             if ($user->isActive()) {
                 if ($user->getEmail()) {
                     $token = Pimcore_Tool_Authentication::generateToken($username, $user->getPassword(), MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
                     $protocol = "http://";
                     if (strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "https") === 0) {
                         $protocol = "https://";
                     }
                     $uri = $protocol . $_SERVER['SERVER_NAME'];
                     $loginUrl = $uri . "/admin/login/login/?username=" . $username . "&token=" . $token;
                     try {
                         $mail = Pimcore_Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
                         $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
                         $mail->send();
                         $this->view->success = true;
                     } catch (Exception $e) {
                         $this->view->error = "could not send email";
                     }
                 } else {
                     $this->view->error = "user has no email address";
                 }
             } else {
                 $this->view->error = "user inactive";
             }
         }
     }
 }
 private function processTagName($name)
 {
     $name = strtolower($name);
     $name = $name == 'col' ? 'td' : $name;
     $name = $name == 'row' ? 'tr' : $name;
     return $name;
 }
Example #14
0
 public function authenticate($user_)
 {
     if (!isset($this->login)) {
         return false;
     }
     return strtolower($this->login) == strtolower($user_->getAttribute('login'));
 }
Example #15
0
 function __construct()
 {
     // Extract the query from the tag chunk
     if (($sql = ee()->TMPL->fetch_param('sql')) === FALSE) {
         return FALSE;
     }
     // Rudimentary check to see if it's a SELECT query, most definitely not
     // bulletproof
     if (substr(strtolower(trim($sql)), 0, 6) != 'select') {
         return FALSE;
     }
     $query = ee()->db->query($sql);
     $results = $query->result_array();
     if ($query->num_rows() == 0) {
         return $this->return_data = ee()->TMPL->no_results();
     }
     // Start up pagination
     ee()->load->library('pagination');
     $pagination = ee()->pagination->create();
     ee()->TMPL->tagdata = $pagination->prepare(ee()->TMPL->tagdata);
     $per_page = ee()->TMPL->fetch_param('limit', 0);
     // Disable pagination if the limit parameter isn't set
     if (empty($per_page)) {
         $pagination->paginate = FALSE;
     }
     if ($pagination->paginate) {
         $pagination->build($query->num_rows(), $per_page);
         $results = array_slice($results, $pagination->offset, $pagination->per_page);
     }
     $this->return_data = ee()->TMPL->parse_variables(ee()->TMPL->tagdata, array_values($results));
     if ($pagination->paginate === TRUE) {
         $this->return_data = $pagination->render($this->return_data);
     }
 }
Example #16
0
 protected function getInput()
 {
     $this->params = $this->element->attributes();
     JHtml::_('jquery.framework');
     NNFrameworkFunctions::addScriptVersion(JUri::root(true) . '/media/nnframework/js/script.min.js');
     if ($file = $this->get('file')) {
         $label = $this->get('label', 'the main extension');
         NNFieldDependency::setMessage($file, $label);
         return '';
     }
     $path = $this->get('path') == 'site' ? '' : '/administrator';
     $label = $this->get('label');
     $file = $this->get('alias', $label);
     $file = preg_replace('#[^a-z-]#', '', strtolower($file));
     $extension = $this->get('extension');
     switch ($extension) {
         case 'com':
             $file = $path . '/components/com_' . $file . '/com_' . $file . '.xml';
             break;
         case 'mod':
             $file = $path . '/modules/mod_' . $file . '/mod_' . $file . '.xml';
             break;
         case 'plg_editors-xtd':
             $file = '/plugins/editors-xtd/' . $file . '.xml';
             break;
         default:
             $file = '/plugins/system/' . $file . '.xml';
             break;
     }
     $label = JText::_($label) . ' (' . JText::_('NN_' . strtoupper($extension)) . ')';
     NNFieldDependency::setMessage($file, $label);
     return '';
 }
Example #17
0
 /**
  * Gets the attribute 'checked'
  * Used with the element 'input' only if type attribute has the value
  * 'radio, checkbox'
  * Case insensitive
  *
  * When the type attribute has the value "radio" or "checkbox",
  * this boolean attribute specifies that the button is on.
  * User agents must ignore this attribute for other control types.
  *
  * @return string Attribute value
  */
 public function getValue()
 {
     if ((int) $this->value === 1 || (bool) $this->value === TRUE || strtolower((string) $this->value === 'checked')) {
         $attribute = 'checked';
     }
     return $attribute;
 }
Example #18
0
/**
 * Sort input array by $subkey
 * Taken from: http://php.net/manual/en/function.ksort.php
 */
function w2l_sksort(&$array, $subkey = "id", $sort_ascending = false)
{
    if (!is_array($array)) {
        return $array;
    }
    $temp_array = array();
    if (count($array)) {
        $temp_array[key($array)] = array_shift($array);
    }
    foreach ($array as $key => $val) {
        $offset = 0;
        $found = false;
        foreach ($temp_array as $tmp_key => $tmp_val) {
            if (!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) {
                $temp_array = array_merge((array) array_slice($temp_array, 0, $offset), array($key => $val), array_slice($temp_array, $offset));
                $found = true;
            }
            $offset++;
        }
        if (!$found) {
            $temp_array = array_merge($temp_array, array($key => $val));
        }
    }
    if ($sort_ascending) {
        $array = array_reverse($temp_array);
    } else {
        $array = $temp_array;
    }
}
Example #19
0
 function get_html($tree = null)
 {
     $tag_name = 'ul';
     $type = '';
     switch ($this->tag) {
         case 'ol':
             $tag_name = 'ol';
             $type = strtolower($this->attrib['ol']);
             break;
         case 'list':
             if ($this->attrib['list']) {
                 $tag_name = 'ol';
             }
             $type = strtolower($this->attrib['list']);
             $this->tag = 'del';
     }
     $attr = ' class="bb"';
     if ('1' == $type) {
         $attr .= ' type="1"';
     } elseif ($type) {
         $attr .= ' type="a"';
     }
     $str = '<' . $tag_name . $attr . '>' . parent::get_html() . '</' . $tag_name . '>';
     return $str;
 }
Example #20
0
 protected function resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive = true)
 {
     /* @var ilObjTest $testOBJ */
     require_once 'Services/Object/classes/class.ilObjectFactory.php';
     $testOBJ = ilObjectFactory::getInstanceByObjId($this->obj_id);
     $testOBJ->removeTestResults($a_user_ids);
     // :TODO: there has to be a better way
     $test_ref_id = (int) $_REQUEST["ref_id"];
     if ($test_ref_id) {
         require_once "Modules/Course/classes/Objectives/class.ilLOSettings.php";
         $course_obj_id = ilLOSettings::isObjectiveTest($test_ref_id);
         if ($course_obj_id) {
             // is test initial and/or qualified?
             $lo_settings = ilLOSettings::getInstanceByObjId($course_obj_id);
             $is_i = $lo_settings->getInitialTest() == $test_ref_id;
             $is_q = $lo_settings->getQualifiedTest() == $test_ref_id;
             // remove objective results data
             require_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
             ilLOUserResults::deleteResultsFromLP($course_obj_id, $a_user_ids, $is_i, $is_q);
             // refresh LP - see ilLPStatusWrapper::_updateStatus()
             require_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $lp_status = ilLPStatusFactory::_getInstance($course_obj_id);
             if (strtolower(get_class($lp_status)) != "illpstatus") {
                 foreach ($a_user_ids as $user_id) {
                     $lp_status->_updateStatus($course_obj_id, $user_id);
                 }
             }
         }
     }
 }
Example #21
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);
 }
Example #22
0
/**
 * Detect HTML in the first KB to prevent against potential security issue with 
 * IE/Safari/Opera file type auto detection bug.
 * Returns true if file contain insecure HTML code at the beginning.
 * 
 * @param string $filePath absolute path to file
 * @return boolean
 */
function DetectHtml($filePath)
{
    $fp = fopen($filePath, 'rb');
    $chunk = fread($fp, 1024);
    fclose($fp);
    $chunk = strtolower($chunk);
    if (!$chunk) {
        return false;
    }
    $chunk = trim($chunk);
    if (preg_match("/<!DOCTYPE\\W*X?HTML/sim", $chunk)) {
        return true;
    }
    $tags = array('<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title');
    foreach ($tags as $tag) {
        if (false !== strpos($chunk, $tag)) {
            return true;
        }
    }
    //type = javascript
    if (preg_match('!type\\s*=\\s*[\'"]?\\s*(?:\\w*/)?(?:ecma|java)!sim', $chunk)) {
        return true;
    }
    //href = javascript
    //src = javascript
    //data = javascript
    if (preg_match('!(?:href|src|data)\\s*=\\s*[\'"]?\\s*(?:ecma|java)script:!sim', $chunk)) {
        return true;
    }
    //url(javascript
    if (preg_match('!url\\s*\\(\\s*[\'"]?\\s*(?:ecma|java)script:!sim', $chunk)) {
        return true;
    }
    return false;
}
Example #23
0
 /**
  * Override main() for help message hook
  *
  * @access public
  */
 function main()
 {
     $this->out(__('I18n Shell', true));
     $this->hr();
     $this->out(__('[E]xtract POT file from sources', true));
     $this->out(__('[I]nitialize i18n database table', true));
     $this->out(__('[H]elp', true));
     $this->out(__('[Q]uit', true));
     $choice = strtolower($this->in(__('What would you like to do?', true), array('E', 'I', 'H', 'Q')));
     switch ($choice) {
         case 'e':
             $this->Extract->execute();
             break;
         case 'i':
             $this->initdb();
             break;
         case 'h':
             $this->help();
             break;
         case 'q':
             exit(0);
             break;
         default:
             $this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.', true));
     }
     $this->hr();
     $this->main();
 }
Example #24
0
 public static function isAdmin($formID, $username = NULL)
 {
     if (isnull($username)) {
         $username = sessionGet("username");
     }
     return self::getCount($formID, $username, mfcs::AUTH_ADMIN) || trim(strtolower(users::user('status', 'user'))) == 'systems';
 }
 /**
  * Executes parent method parent::render(), creates deliveryset category tree,
  * passes data to Smarty engine and returns name of template file "deliveryset_main.tpl".
  *
  * @return string
  */
 public function render()
 {
     $myConfig = $this->getConfig();
     parent::render();
     $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $odeliveryset = oxNew("oxdeliveryset");
         $odeliveryset->loadInLang($this->_iEditLang, $soxId);
         $oOtherLang = $odeliveryset->getAvailableInLangs();
         if (!isset($oOtherLang[$this->_iEditLang])) {
             // echo "language entry doesn't exist! using: ".key($oOtherLang);
             $odeliveryset->loadInLang(key($oOtherLang), $soxId);
         }
         $this->_aViewData["edit"] = $odeliveryset;
         // remove already created languages
         $aLang = array_diff(oxLang::getInstance()->getLanguageNames(), $oOtherLang);
         if (count($aLang)) {
             $this->_aViewData["posslang"] = $aLang;
         }
         foreach ($oOtherLang as $id => $language) {
             $oLang = new oxStdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = clone $oLang;
         }
     }
     if (oxConfig::getParameter("aoc")) {
         $aColumns = array();
         include_once 'inc/' . strtolower(__CLASS__) . '.inc.php';
         $this->_aViewData['oxajax'] = $aColumns;
         return "popups/deliveryset_main.tpl";
     }
     return "deliveryset_main.tpl";
 }
 /**
  * {@inheritdoc}
  */
 public function extract($command)
 {
     $className = substr(strrchr(get_class($command), '\\'), 1);
     return preg_replace_callback('/(^|[a-z])([A-Z])/', function ($s) {
         return strtolower(strlen($s[1]) ? "{$s['1']}_{$s['2']}" : "{$s['2']}");
     }, $className);
 }
Example #27
0
 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     /* 设置文件保存位置 */
     $this->_auto[] = array('location', 'ftp' === strtolower($driver) ? 1 : 0, self::MODEL_INSERT);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
                 continue;
             }
             $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
             //在模板里的url路径
             /* 记录文件信息 */
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
Example #28
0
 public function create_column($column)
 {
     $column['column_name'] = strtolower($column['column_name']);
     $column['data_type'] = strtolower(preg_replace('/\\(.*?\\)/', '', $column['data_type']));
     if ($column['data_default'] !== null) {
         $column['data_default'] = trim($column['data_default'], "' ");
     }
     if ($column['data_type'] == 'number') {
         if ($column['data_scale'] > 0) {
             $column['data_type'] = 'decimal';
         } elseif ($column['data_scale'] == 0) {
             $column['data_type'] = 'int';
         }
     }
     $c = new Column();
     $c->inflected_name = Inflector::instance()->variablize($column['column_name']);
     $c->name = $column['column_name'];
     $c->nullable = $column['nullable'] == 'Y' ? true : false;
     $c->pk = $column['pk'] == 'P' ? true : false;
     $c->length = $column['data_length'];
     if ($column['data_type'] == 'timestamp') {
         $c->raw_type = 'datetime';
     } else {
         $c->raw_type = $column['data_type'];
     }
     $c->map_raw_type();
     $c->default = $c->cast($column['data_default']);
     return $c;
 }
 /**
  * generates a url to the current page
  * @param  boolean $dropqs [description]
  * @return string          [description]
  */
 public static function php_self($dropqs = true)
 {
     // figure out what the protocol is
     $protocol = 'http';
     if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
         $protocol = 'https';
     } elseif (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
         $protocol = 'https';
     }
     // figure out what the server name is
     $serverName = empty($_SERVER['SERVER_NAME']) ? 'localhost' : $_SERVER['SERVER_NAME'];
     // figure out what the port is
     $port = empty($_SERVER['SERVER_PORT']) ? 80 : $_SERVER['SERVER_PORT'];
     // build the uri
     $url = sprintf('%s://%s%s', $protocol, $serverName, $_SERVER['REQUEST_URI']);
     $parts = parse_url($url);
     $port = $port;
     $scheme = $parts['scheme'];
     $host = $parts['host'];
     $path = @$parts['path'];
     $qs = @$parts['query'];
     $port or $port = $scheme == 'https' ? '443' : '80';
     if ($scheme == 'https' && $port != '443' || $scheme == 'http' && $port != '80') {
         $host = "{$host}:{$port}";
     }
     $url = $scheme . '://' . $host . $path;
     if (!$dropqs) {
         return "{$url}?{$qs}";
     } else {
         return $url;
     }
 }
Example #30
-1
 public function action_discrepancies()
 {
     if (!Group::current('is_admin')) {
         throw new HTTP_Exception_403('Forbidden');
     }
     $list = Database_Mongo::collection('jobs')->find(array('discrepancies' => array('$nin' => array(NULL, '', 0))));
     $ids = array();
     foreach ($list as $job) {
         $discr = Database_Mongo::collection('discrepancies')->find(array('job_key' => $job['_id']))->sort(array('update_time' => -1))->getNext();
         $fl = true;
         foreach ($discr['data'] as $key => $value) {
             if ($key == 44) {
                 $status = preg_replace('/[^a-z]/i', '', strtolower($value['old_value']));
                 $status2 = preg_replace('/[^a-z]/i', '', strtolower($value['new_value']));
                 $status0 = preg_replace('/[^a-z]/i', '', strtolower(Arr::get($job['data'], $key, '')));
                 if ($status == $status0) {
                     continue;
                 }
                 if ($status == 'tested' && $status2 != 'tested' || $status == 'built' && ($status2 != 'built' && $status2 != 'tested') || $status != $status2 && in_array($status2, array('deferred', 'dirty', 'heldnbn'), true)) {
                     $fl = false;
                     continue;
                 }
             } elseif ($value['old_value'] != Arr::get($job['data'], $key, '')) {
                 $fl = false;
                 continue;
             }
         }
         if ($fl) {
             $ids[] = $job['_id'];
         }
     }
     Database_Mongo::collection('jobs')->update(array('_id' => array('$in' => $ids)), array('$unset' => array('discrepancies' => 1)), array('multiple' => 1));
     header('Content-type: application/json');
     die(json_encode(array('success' => true)));
 }