/** * @inheritdoc */ public function init() { parent::init(); //Convert fileInputOptions[accept] to a string because we need it further more to send as property in file rule see[[createMediaJs()]]. if (array_key_exists('accept', $this->fileInputOptions)) { if (is_array($this->fileInputOptions['accept'])) { implode(',', $this->fileInputOptions['accept']); } } else { $this->fileInputOptions['accept'] = 'image/*'; } //Convert acceptFileExtension to a string because we need it further more to send as property in file rule see[[createMediaJs()]]. if (is_array($this->acceptFileExtensions)) { implode(',', $this->acceptFileExtensions); } $aft = str_replace(',', '|', $this->acceptFileExtensions); $this->clientOptions['acceptFileTypes'] = new \yii\web\JsExpression("/(\\.|\\/)({$aft})\$/i"); $this->fileInputOptions['multiple'] = true; //Set default client options $clientOptions['maxNumberOfFiles'] = 100; $clientOptions['maxFileSize'] = 10000000; $clientOptions['minFileSize'] = 100; $this->clientOptions = array_merge($clientOptions, $this->clientOptions); //Messages i18n $messages = ['maxNumberOfFiles' => Yii::t('media', 'You can only upload {n,plural,=1{one file} other{# files}}.', ['n' => $this->clientOptions['maxNumberOfFiles']]), 'acceptFileTypes' => Yii::t('media', 'Only {filetypes} are allowed.', ['filetypes' => $this->acceptFileExtensions]), 'maxFileSize' => Yii::t('media', 'The maximum filesize is {filesize}.', ['filesize' => $this->clientOptions['maxFileSize']]), 'minFileSize' => Yii::t('media', 'The minimum filesize is {filesize}.', ['filesize' => $this->clientOptions['minFileSize']])]; if (array_key_exists('messages', $this->clientOptions) && isArray($this->clientOptions['messages'])) { $this->clientOptions = array_merge($messages, $this->clientOptions['messages']); } else { $this->clientOptions['messages'] = $messages; } $this->options['id'] = $this->fileInputOptions['id'] . '-fileupload'; $this->options['data-upload-template-id'] = $this->uploadTemplateId ?: 'template-upload'; $this->options['data-download-template-id'] = $this->downloadTemplateId ?: 'template-download'; }
function isArrayAndReturnValue($val, $index) { if (isArray($val) && array_key_exists($index, $val)) { return $val[$index]; } throwError("The array doesn't has {$index}"); }
public function selectColumnByColumnUnique($column, $columnunique, $columnuniquevalue) { $vars = $this->vars; if ($this->getCount() > 0 && isset($this->vars[$columnuniquevalue])) { foreach ($vars as $line) { if (isset($line[$columnunique]) && !isArray($line[$column]) && strcmp($line[$columnunique], $columnuniquevalue) == 0) { return $line[$column]; } } } return ""; }
static function get_head_script_styles() { $script_names = array("jquery", "jquery-1.7.1.min", "jquery-ui-1.8.19.custom.min", "ajax"); $styles_names = array("jquery.jscrollpane.lozenge", "jquery-ui-1.8.19.custom"); $head_balise = '<link rel="icon" type="image/png" href="' . get_http_url() . 'logo.png" />'; if (isArray($script_names)) { foreach ($script_names as $value) { $head_balise .= "<script type='text/javascript' src='" . get_http_url() . DEFAULT_JS_DIR . $value . ".js'></script>"; } } if (isArray($styles_names)) { foreach ($styles_names as $value) { $head_balise .= "<link type='text/css' href='" . get_http_url() . DEFAULT_CSS_DIR . $value . ".css' rel='stylesheet' media='all' />"; } } return $head_balise; }
/** * SOAP::Value::_getSoapType * * convert php type to soap type * @param string value * @param string type - presumed php type * * @return string type - soap type * @access private */ function _getSoapType(&$value, &$type) { $doconvert = FALSE; if (0 && $this->wsdl) { # see if it's a complex type so we can deal properly with SOAPENC:arrayType if (!$type && $this->name) { # XXX TODO: # look up the name in the wsdl and validate the type $this->debug("SOAP_VALUE no type for {$this->name}!"); } else { if ($type) { # XXX TODO: # this code currently handles only one way of encoding array types in wsdl # need to do a generalized function to figure out complex types if (array_key_exists($type, $this->wsdl->complexTypes)) { if ($this->arrayType = $this->wsdl->complexTypes[$type]['arrayType']) { $type = 'Array'; } else { if ($this->wsdl->complexTypes[$type]['order'] == 'sequence' && array_key_exists('elements', $this->wsdl->complexTypes[$type])) { reset($this->wsdl->complexTypes[$type]['elements']); # assume an array if (count($this->wsdl->complexTypes[$type]['elements']) == 1) { $arg = current($this->wsdl->complexTypes[$type]['elements']); $this->arrayType = $arg['type']; $type = 'Array'; } else { foreach ($this->wsdl->complexTypes[$type]['elements'] as $element) { if ($element['name'] == $type) { $this->arrayType = $element['type']; $type = $element['type']; } } } } } } } } } if (!$type || !$this->verifyType($type)) { if ($type && $this->wsdl && array_key_exists($type, $this->wsdl->complexTypes)) { # do nothing, this preserves our complex types } else { if (is_object($value)) { # allows for creating special classes to handle soap types $type = get_class($value); # this may return a different type that we process below $value = $value->toSOAP(); } elseif (isArray($value)) { $type = isHash($value) ? 'Struct' : 'Array'; } elseif (isInt($value)) { $type = 'int'; } elseif (isFloat($value)) { $type = 'float'; } elseif (SOAP_Type_hexBinary::is_hexbin($value)) { $type = 'hexBinary'; } elseif (isBase64($value)) { $type = 'base64Binary'; } elseif (isBoolean($value)) { $type = 'boolean'; } else { $type = gettype($value); # php defaults a lot of stuff to string, if we have no # idea what the type realy is, we have to try to figure it out # this is the best we can do if the user did not use the SOAP_Value class if ($type == 'string') { $doconvert = TRUE; } } } } # we have the type, handle any value munging we need if ($doconvert) { $dt = new SOAP_Type_dateTime($value); if ($dt->toUnixtime() != -1) { $type = 'dateTime'; $value = $dt->toSOAP(); } } else { if ($type == 'dateTime') { # encode a dateTime to ISOE $dt = new SOAP_Type_dateTime($value); $value = $dt->toSOAP(); } else { // php type name mangle if ($type == 'integer') { $type = 'int'; } else { if ($type == 'boolean') { if ($value != 0 && $value != '0' || strcasecmp($value, 'true') == 0) { $value = 'true'; } else { $value = 'false'; } } } } } return $type; }
/** * Get alias function. * * @param object $self Same with object $this * @param string $method Call which funciton * @param object $caller Caller * * @return mixed */ public function get($self, $method, $caller) { if (!is_callable([$self, 'getDir'])) { return false; } $path = $self->getDir() . 'src/_' . $method . '.php'; if (!realpath($path)) { return false; } $r = l($path, _INIT_CONFIG); if (!isset($r->var[_INIT_CONFIG][_CLASS])) { return !trigger_error('Not defined default Class'); } else { $class = $r->var[_INIT_CONFIG][_CLASS]; if (!class_exists($class)) { return !trigger_error('Default Class not exits. [' . $class . ']'); } $func = new $class($caller); $func->caller = $caller; } if (!is_callable($func)) { return !trigger_error('Not implement __invoke function'); } if (isArray($self) && !isset($self[$method])) { $self[$method] = $func; } elseif (!isset($self->{$method})) { $self->{$method} = $func; } return $func; }
protected function _wh($column, $value, $logical, $type = 'where') { if (isArray($column)) { $columns = func_get_args(); if (isset($columns[0][0]) && is_array($columns[0][0])) { $columns = $columns[0]; } foreach ($columns as $col) { if (is_array($col)) { $c = isset($col[0]) ? $col[0] : ''; $v = isset($col[1]) ? $col[1] : ''; $l = isset($col[2]) ? $col[2] : ''; $this->{$type} .= $this->_whereHaving($c, $v, $l); } } } else { $this->{$type} .= $this->_whereHaving($column, $value, $logical); } return $this; }
function fIsArray() { return function ($d) { return isArray($d); }; }
/** * Creates a thumbnail and save it to the given url. This function is called from [[thumb]] function * @param string $url The url to the original image file * @param array A thumbnail configuration array or a [[thumbStyle]] * @return The thumbnail url */ protected function createThumb($url, $config) { if (is_string($config)) { if ($this->thumbExtraDirectory === true) { $thumbDirectory = $this->thumbDirectory . DIRECTORY_SEPARATOR . $config; $suffix = ''; } else { $thumbDirectory = $this->thumbDirectory; $suffix = '_' . $config; } $config = $this->thumbStyles[$config]; } elseif ($this->thumbExtraDirectory === false || isArray($config)) { $thumbDirectory = $this->thumbDirectory; $suffix = '_' . $config[0] . 'x' . $config[1]; } $info = !Url::isRelative($url) ? pathinfo(parse_url($url, PHP_URL_PATH)) : pathinfo($url); $dirname = ltrim($info['dirname'], '/\\'); $thumbPath = Yii::getAlias('@webroot') . DIRECTORY_SEPARATOR . $dirname . DIRECTORY_SEPARATOR . $thumbDirectory; $thumbName = $info['filename'] . $suffix . '.' . $info['extension']; if (!file_exists($thumbPath . DIRECTORY_SEPARATOR . $thumbName)) { if (!$suffix) { FileHelper::createDirectory($thumbPath, 0766); } //Create and save the thumbnail list($width, $height, $quality, $func) = $config; try { \kmergen\media\helpers\Image::$func($url, $width, $height)->save($thumbPath . DIRECTORY_SEPARATOR . $thumbName, ['quality' => $quality]); } catch (Exception $ex) { if ($ex instanceof \Imagine\Exception\InvalidArgumentException) { Yii::info('Imagine Invalid Argument Exception: ' . $ex->getMessage() . ' in file ' . $ex->getFile() . ' on line ' . $ex->getLine() . '.'); } else { Yii::info('Imagine Exception: ' . $ex->getMessage() . ' in file ' . $ex->getFile() . ' on line ' . $ex->getLine() . '.'); } throw new Exception($ex->getMessage()); } } $thumbDirectory = str_replace('\\', '/', $thumbDirectory); return Yii::getAlias('@web') . '/' . $dirname . '/' . $thumbDirectory . '/' . $thumbName; }
protected function _extras($extras) { if (isArray($extras)) { $extraCodes = ' ' . implode(' ', $extras) . ';'; } elseif (is_string($extras)) { $extraCodes = ' ' . $extras . ';'; } else { $extraCodes = ''; } return $extraCodes; }
function internalCreateRobotsFile() { $rules = Config::get('Robots', 'rules'); $robots = ''; if (isArray($rules)) { foreach ($rules as $key => $val) { if (!is_numeric($key)) { switch ($key) { case 'userAgent': $robots .= !empty($val) ? 'User-agent: ' . $val . EOL : ''; break; case 'allow': case 'disallow': if (!empty($val)) { foreach ($val as $v) { $robots .= ucfirst($key) . ': ' . $v . EOL; } } break; } } else { if (isArray($val)) { foreach ($val as $r => $v) { switch ($r) { case 'userAgent': $robots .= !empty($v) ? 'User-agent: ' . $v . EOL : ''; break; case 'allow': case 'disallow': if (!empty($v)) { foreach ($v as $vr) { $robots .= ucfirst($r) . ': ' . $vr . EOL; } } break; } } } } } } $robotTxt = 'robots.txt'; // robots.txt dosyası varsa içeriği al yok ise içeriği boş geç if (File::exists($robotTxt)) { $getContents = File::read($robotTxt); } else { $getContents = ''; } // robots.txt değişkenin tuttuğu değer ile dosya içeri eşitse tekrar oluşturma if (trim($robots) === trim($getContents)) { return false; } if (!File::write($robotTxt, trim($robots))) { throw new GeneralException('Error', 'fileNotWrite', $robotTxt); } }
protected function _thead($columns, $countColumns) { $table = '<thead>' . EOL; $table .= '<tr' . Html::attributes(VIEWOBJECTS_DATAGRID_CONFIG['attributes']['columns']) . '>'; $table .= '<td colspan="2">'; $table .= Form::open('addForm') . Form::placeholder(VIEWOBJECTS_DATAGRID_CONFIG['placeHolders']['search'])->id('datagridSearch')->attr(VIEWOBJECTS_DATAGRID_CONFIG['attributes']['search'])->text('search') . Form::close(); $table .= '</td><td colspan="' . ($countColumns - 1) . '"></td><td align="right" colspan="2">'; $table .= Form::action(CURRENT_CFPATH . (URI::get('page') ? '/page/' . URI::get('page') : NULL) . '/process/add')->open('addForm') . Form::attr(VIEWOBJECTS_DATAGRID_CONFIG['attributes']['add'])->submit('addButton', VIEWOBJECTS_DATAGRID_CONFIG['buttonNames']['add']) . Form::close(); $table .= '</tr><tr' . Html::attributes(VIEWOBJECTS_DATAGRID_CONFIG['attributes']['columns']) . '>'; $table .= '<td width="20">#</td>'; //---------------------------------------------------------------------------------------------------- // Head Columns //---------------------------------------------------------------------------------------------------- // // Üst sütun bölümü. // //---------------------------------------------------------------------------------------------------- if (isArray($columns)) { foreach ($columns as $column) { $table .= '<td>' . Html::anchor(CURRENT_CFPATH . '/order/' . $column . '/type/' . (URI::get('type') === 'asc' ? 'desc' : 'asc'), Html::strong($column), VIEWOBJECTS_DATAGRID_CONFIG['attributes']['columns']) . '</td>'; } } $table .= '<td align="right" colspan="2"><span' . Html::attributes(VIEWOBJECTS_DATAGRID_CONFIG['attributes']['columns']) . '>' . Html::strong(VIEWOBJECTS_DBGRID_LANG['processLabel']) . '</span></td>'; $table .= '</tr>' . EOL; $table .= '</thead>' . EOL; return $table; }
/** * @package:SMS * @getOrientedDecision::getStudentsCgpa(). * @Author:Techno Services */ function getStudentsCgpa($std_id, $semster) { $ci = getInstance(); $total_marks = array(); $total_credit = array(); if ($std_id) { $where['student_id'] = $std_id; $where['semester'] = $semster; $table = $ci->common_model->_studentsMarksTable; $sqlStudents = $ci->common_model->getRecords($table, $where, 'all'); if (isArray($sqlStudents) && isset($sqlStudents[0])) { foreach ($sqlStudents as $lists) { $sql_credit = $ci->common_model->getRecords($ci->common_model->_courseTable, array("ID" => $lists->course_id), 's'); $marks = calculatetMarksheetMarks($lists->quiz, $lists->exam); $total_sub = caltMarksheetTotalSubMarks($marks, $sql_credit['course_credit']); $total_marks[] = $total_sub; $total_credit[] = $sql_credit['course_credit']; } } } return isArray($total_marks) && isArray($total_credit) ? getGpa($total_marks, $total_credit) : 0; }
/** * @return \Closure */ function isNotArray() { return negate(isArray()); }