Exemple #1
0
 /**
  * @example 'smart-dizayn'
  */
 public function domainWord()
 {
     $company = $this->generator->format('companyUrl');
     $company = str_replace(' ', '-', $company);
     $company = Transliteration::transliterate($company);
     return $company;
 }
Exemple #2
0
 /**
  * Translate Arabic or English word into Hieroglyphics
  *      
  * @param string  $word  Arabic or English word
  * @param string  $dir   Writing direction [ltr, rtl, ttd, dtt] (default ltr)
  * @param string  $lang  Input language [en, ar] (default en)
  * @param integer $red   Value of background red component (default is null)
  * @param integer $green Value of background green component (default is null)
  * @param integer $blue  Value of background blue component (default is null)
  *      
  * @return resource Image resource identifier
  * @author Khaled Al-Sham'aa <*****@*****.**>
  */
 public function str2graph($word, $dir = 'ltr', $lang = 'en', $red = null, $green = null, $blue = null)
 {
     if ($this->_language == 'phoenician') {
         define(MAXH, 40);
         define(MAXW, 50);
     } else {
         define(MAXH, 100);
         define(MAXW, 75);
     }
     // Note: there is no theh, khah, thal, dad, zah, and ghain in Phoenician
     $arabic = array('ا' => 'alef', 'ب' => 'beh', 'ت' => 'teh', 'ث' => 'theh', 'ج' => 'jeem', 'ح' => 'hah', 'خ' => 'khah', 'د' => 'dal', 'ذ' => 'thal', 'ر' => 'reh', 'ز' => 'zain', 'س' => 'seen', 'ش' => 'sheen', 'ص' => 'sad', 'ض' => 'dad', 'ط' => 'tah', 'ظ' => 'zah', 'ع' => 'ain', 'غ' => 'ghain', 'ف' => 'feh', 'ق' => 'qaf', 'ك' => 'kaf', 'ل' => 'lam', 'م' => 'meem', 'ن' => 'noon', 'ه' => 'heh', 'و' => 'waw', 'ي' => 'yeh');
     if ($lang != 'ar' && $this->_language == 'phoenician') {
         include dirname(__FILE__) . '/Transliteration.php';
         $temp = new Transliteration();
         $word = $temp->en2ar($word);
         $temp = null;
         $lang = 'ar';
     }
     if ($lang != 'ar') {
         $word = strtolower($word);
     } else {
         $word = str_replace('ة', 'ت', $word);
         $alef = array('ى', 'ؤ', 'ئ', 'ء', 'آ', 'إ', 'أ');
         $word = str_replace($alef, '?', $word);
     }
     $chars = array();
     $max = mb_strlen($word, 'UTF-8');
     for ($i = 0; $i < $max; $i++) {
         $chars[] = mb_substr($word, $i, 1, 'UTF-8');
     }
     if ($dir == 'rtl' || $dir == 'btt') {
         $chars = array_reverse($chars);
     }
     $max_w = 0;
     $max_h = 0;
     foreach ($chars as $char) {
         if ($lang == 'ar') {
             $char = $arabic[$char];
         }
         if (file_exists(dirname(__FILE__) . "/images/{$this->_language}/{$char}.gif")) {
             list($width, $height) = getimagesize(dirname(__FILE__) . "/images/{$this->_language}/{$char}.gif");
         } else {
             $width = MAXW;
             $height = MAXH;
         }
         if ($dir == 'ltr' || $dir == 'rtl') {
             $max_w += $width;
             if ($height > $max_h) {
                 $max_h = $height;
             }
         } else {
             $max_h += $height;
             if ($width > $max_w) {
                 $max_w = $width;
             }
         }
     }
     $im = imagecreatetruecolor($max_w, $max_h);
     if ($red == null) {
         $bck = imagecolorallocate($im, 0, 0, 255);
         imagefill($im, 0, 0, $bck);
         // Make the background transparent
         imagecolortransparent($im, $bck);
     } else {
         $bck = imagecolorallocate($im, $red, $green, $blue);
         imagefill($im, 0, 0, $bck);
     }
     $current_x = 0;
     foreach ($chars as $char) {
         if ($lang == 'ar') {
             $char = $arabic[$char];
         }
         $filename = dirname(__FILE__) . "/images/{$this->_language}/{$char}.gif";
         if ($dir == 'ltr' || $dir == 'rtl') {
             if (file_exists($filename)) {
                 list($width, $height) = getimagesize($filename);
                 $image = imagecreatefromgif($filename);
                 imagecopy($im, $image, $current_x, $max_h - $height, 0, 0, $width, $height);
             } else {
                 $width = MAXW;
             }
             $current_x += $width;
         } else {
             if (file_exists($filename)) {
                 list($width, $height) = getimagesize($filename);
                 $image = imagecreatefromgif($filename);
                 imagecopy($im, $image, 0, $current_y, 0, 0, $width, $height);
             } else {
                 $height = MAXH;
             }
             $current_y += $height;
         }
     }
     return $im;
 }
 /**
  * Ajax photoreloader
  * @param integer $id
  */
 public function actionReloadphoto($id)
 {
     try {
         $temp_dir = sys_get_temp_dir();
         $model = $this->loadModel($id);
         //$model = new Person;
         //$model->scenario = "PHOTO";
         $edbeo_file = WebServices::getPersonPhotoByCodeU($model->codeU);
         if (!empty($edbeo_file)) {
             $oldPhoto = $model->PhotoName;
             $tfio = Transliteration::translit2010($model->FirstName) . "_" . Transliteration::translit2010($model->LastName) . "_" . Transliteration::translit2010($model->MiddleName);
             $model->PhotoName = "person_{$id}" . "_{$tfio}.jpg";
             $path = Yii::app()->basePath . "/.." . Yii::app()->params['photosPath'];
             $bigpath = Yii::app()->basePath . "/.." . Yii::app()->params['photosBigPath'];
             $img = EWideImage::loadFromString(base64_decode($edbeo_file));
             if ($img->getWidth() < $img->getHeight()) {
                 $img->resize(120, null)->crop("center", "middle", 120, 150)->saveToFile($path . "person_{$id}" . "_{$tfio}.jpg");
                 $img->resize(180, null)->crop("center", "middle", 180, 225)->saveToFile($bigpath . "person_{$id}" . "_{$tfio}.jpg");
             } else {
                 $img->resize(null, 150)->crop("center", "middle", 120, 150)->saveToFile($path . "person_{$id}" . "_{$tfio}.jpg");
                 $img->resize(null, 225)->crop("center", "middle", 180, 225)->saveToFile($bigpath . "person_{$id}" . "_{$tfio}.jpg");
             }
             if ($model->save()) {
                 //PC::debug($model->PhotoName);
             } else {
                 //PC::debug(print_r($model->getErrors()));
             }
             echo CJSON::encode(array("result" => "SUCCESS", "data" => Yii::app()->request->baseUrl . Yii::app()->params['photosPath'] . $model->PhotoName));
         } else {
             echo CJSON::encode(array("result" => "ERROR", "data" => "Фото відсутнє!"));
         }
     } catch (Exception $e) {
         if (defined('YII_DEBUG')) {
             Yii::log($e->getMessage(), CLogger::LEVEL_INFO, 'actionReloadphoto');
         }
         echo CJSON::encode(array("result" => "ERROR", "data" => $e->getMessage()));
     }
 }
Exemple #4
0
 /**
  * Helper function to process the media filename according to the settings
  *
  * @return string
  *  The parsed filename
  */
 private function getFilename()
 {
     switch (config('media.config.rename')) {
         case 'transliterate':
             $this->filename_new = \Transliteration::clean_filename($this->filename_original);
             break;
         case 'unique':
             $this->filename_new = md5(microtime() . str_random(5)) . '.' . $this->filename_original;
             break;
         case 'nothing':
             $this->filename_new = $this->file->getClientOriginalName();
             break;
     }
     return $this->fileExistsRename();
 }
Exemple #5
0
 protected function beforeSave()
 {
     unset($this->CreateDate);
     if ($this->KOATUUCodeL1ID == "0") {
         $this->KOATUUCodeL1ID = NULL;
     }
     if ($this->KOATUUCodeL2ID == "0") {
         $this->KOATUUCodeL2ID = NULL;
     }
     if ($this->KOATUUCodeL3ID == "0") {
         $this->KOATUUCodeL3ID = NULL;
     }
     if ($this->SchoolID == "0") {
         $this->SchoolID = NULL;
     }
     // $from=DateTime::createFromFormat('d.m.Y',$this->Birthday);
     $this->Birthday = date('Y-m-d', strtotime($this->Birthday));
     if (!empty($this->koatu)) {
         $koatu = explode(";", $this->koatu);
         $this->KOATUUCodeID = $koatu[0];
         $this->KOATUUCode = $koatu[1];
     }
     $kk = KoatuuLevel3::model()->findByPk($this->KOATUUCodeID);
     if (!empty($kk)) {
         //$kk = new KoatuuLevel3();
         // Yii::log($this->KOATUUCodeID);
         $this->KOATUUCodeL3ID = $this->KOATUUCodeID;
         $kk2 = KoatuuLevel2::model()->findByPk($kk->KOATUULevel2ID);
         $this->KOATUUCodeL2ID = $kk->KOATUULevel2ID;
         $this->KOATUUCodeL1ID = $kk2->KOATUULevel1ID;
     } else {
         $kk = KoatuuLevel2::model()->findByPk($this->KOATUUCodeID);
         if (!empty($kk)) {
             ///Yii::log($this->KOATUUCodeID);
             $this->KOATUUCodeL2ID = $this->KOATUUCodeID;
             $this->KOATUUCodeL1ID = $kk->KOATUULevel1ID;
         } else {
             Yii::log($this->KOATUUCodeID);
             $kk = KoatuuLevel3::model()->findByPk($this->KOATUUCodeID);
             if (!empty($kk)) {
                 $this->KOATUUCodeL1ID = $this->KOATUUCodeID;
             }
         }
     }
     if (empty($this->LastNameEn)) {
         $this->LastNameEn = Transliteration::translit2010($this->LastName);
     }
     if (empty($this->MiddleNameEn)) {
         $this->MiddleNameEn = Transliteration::translit2010($this->MiddleName);
     }
     if (empty($this->FirstNameEn)) {
         $this->FirstNameEn = Transliteration::translit2010($this->FirstName);
     }
     if (!Yii::app()->user->checkAccess("editResident")) {
         if ($this->CountryID != 804) {
             $this->IsResident = 0;
         } else {
             $this->IsResident = 1;
         }
     }
     if ($this->edboID == 0) {
         $this->edboID = "";
     }
     parent::beforeSave();
     return true;
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $this->layout = '//layouts/column2_noblock';
     $model = $this->loadModel($id);
     //var_dump($_POST);
     //var_dump($model);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Person'])) {
         $model->attributes = $_POST['Person'];
         if (empty($_POST['Person']['KOATUUCodeL2ID'])) {
             $model->KOATUUCodeL2ID = null;
         }
         if (empty($_POST['Person']['KOATUUCodeL3ID'])) {
             $model->KOATUUCodeL3ID = null;
         }
         /*if (isset($_POST['Documents']['inndoc'])) {
               $model->inndoc->attributes = $_POST['Documents']['inndoc'];
               $model->inndoc->PersonID = $model->idPerson;
           }*/
         if (isset($_POST['PersonContacts']['homephone'])) {
             $model->homephone->attributes = $_POST['PersonContacts']['homephone'];
             $model->homephone->PersonID = $model->idPerson;
         }
         if (isset($_POST['PersonContacts']['mobphone'])) {
             $model->mobphone->attributes = $_POST['PersonContacts']['mobphone'];
             $model->mobphone->PersonID = $model->idPerson;
         }
         //if ($model->validate() && $model->inndoc->validate("INN") && $model->homephone->validate() && $model->mobphone->validate() && $model->save()) {
         if ($model->validate() && $model->homephone->validate() && $model->mobphone->validate() && $model->save()) {
             $file = CUploadedFile::getInstance($model, 'image');
             if (!empty($file)) {
                 $tfio = Transliteration::text($model->FirstName) . "_" . Transliteration::text($model->LastName) . "_" . Transliteration::text($model->MiddleName);
                 $path = Yii::app()->basePath . "/.." . Yii::app()->params['photosPath'];
                 $bigpath = Yii::app()->basePath . "/.." . Yii::app()->params['photosBigPath'];
                 $img = EWideImage::loadFromFile($file->getTempName());
                 if (file_exists($path . "person_{$id}" . "_{$tfio}.jpg")) {
                     unlink($path . "person_{$id}" . "_{$tfio}.jpg");
                 }
                 if (file_exists($bigpath . "person_{$id}" . "_{$tfio}.jpg")) {
                     unlink($bigpath . "person_{$id}" . "_{$tfio}.jpg");
                 }
                 if ($img->getWidth() < $img->getHeight()) {
                     $img->resize(120, null)->crop("center", "middle", 120, 150)->saveToFile($path . "person_{$id}" . "_{$tfio}.jpg");
                     $img->resize(180, null)->crop("center", "middle", 180, 225)->saveToFile($bigpath . "person_{$id}" . "_{$tfio}.jpg");
                 } else {
                     $img->resize(null, 150)->crop("center", "middle", 120, 150)->saveToFile($path . "person_{$id}" . "_{$tfio}.jpg");
                     $img->resize(null, 225)->crop("center", "middle", 180, 225)->saveToFile($bigpath . "person_{$id}" . "_{$tfio}.jpg");
                 }
                 unlink($file->getTempName());
                 $model->PhotoName = "person_{$id}" . "_{$tfio}.jpg";
                 $model->save();
             }
             //$model->inndoc->save();
             $model->homephone->save();
             $model->mobphone->save();
             //$model->SendEdboRequest();
             $this->redirect(array('view', 'id' => $model->idPerson));
         }
     }
     $this->render('update', array('model' => $model));
 }
 public function showAllLine($scripture_id = 1, $translation = 13, $transliteration = 69)
 {
     $data = Scripture::line($scripture_id)->firstOrFail();
     $data['translation'] = Translation::only($data->id, $translation)->firstOrFail()->toArray();
     $data['transliteration'] = Transliteration::only($data->id, $transliteration)->firstOrFail()->toArray();
     $this->throwError($data);
     return Response::json($data);
 }