当前位置: 首页>>代码示例>>PHP>>正文


PHP Jaws_Utils::is_writable方法代码示例

本文整理汇总了PHP中Jaws_Utils::is_writable方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Utils::is_writable方法的具体用法?PHP Jaws_Utils::is_writable怎么用?PHP Jaws_Utils::is_writable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jaws_Utils的用法示例。


在下文中一共展示了Jaws_Utils::is_writable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Install

 /**
  * Install the gadget
  *
  * @access  public
  * @param   string  $input_schema       Schema file path
  * @param   array   $input_variables    Schema variables
  * @return  mixed   True on success or Jaws_Error on failure
  */
 function Install($input_schema = '', $input_variables = array())
 {
     if (!Jaws_Utils::is_writable(JAWS_DATA)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', JAWS_DATA));
     }
     $new_dir = JAWS_DATA . 'blog' . DIRECTORY_SEPARATOR . 'images';
     if (!Jaws_Utils::mkdir($new_dir, 1)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir));
     }
     $new_dir = JAWS_DATA . 'xml' . DIRECTORY_SEPARATOR;
     if (!Jaws_Utils::mkdir($new_dir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir));
     }
     $result = $this->installSchema('schema.xml');
     if (Jaws_Error::IsError($result)) {
         return $result;
     }
     $variables = array();
     $variables['timestamp'] = Jaws_DB::getInstance()->date();
     $result = $this->installSchema('insert.xml', $variables, 'schema.xml', true);
     if (Jaws_Error::IsError($result)) {
         return $result;
     }
     if (!empty($input_schema)) {
         $result = $this->installSchema($input_schema, $input_variables, 'schema.xml', true);
         if (Jaws_Error::IsError($result)) {
             return $result;
         }
     }
     $this->gadget->acl->insert('CategoryAccess', 1, true);
     $this->gadget->acl->insert('CategoryManage', 1, true);
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:41,代码来源:Installer.php

示例2: packTheme

 /**
  * Creates a .zip file of the theme in themes/ directory
  *
  * @access  public
  * @param   string  $theme      Name of the theme
  * @param   string  $srcDir     Source directory
  * @param   string  $destDir    Target directory
  * @param   bool    $copy_example_to_repository  If copy example.png too or not
  * @return  bool    Returns true if:
  *                    - Theme exists
  *                    - Theme exists and could be packed
  *                  Returns false if:
  *                    - Theme doesn't exist
  *                    - Theme doesn't exists and couldn't be packed
  */
 function packTheme($theme, $srcDir, $destDir, $copy_example_to_repository = true)
 {
     $themeSrc = $srcDir . '/' . $theme;
     if (!is_dir($themeSrc)) {
         return new Jaws_Error(_t('TMS_ERROR_THEME_DOES_NOT_EXISTS', $theme));
     }
     if (!Jaws_Utils::is_writable($destDir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', $destDir), $this->gadget->name);
     }
     $themeDest = $destDir . '/' . $theme . '.zip';
     //If file exists.. delete it
     if (file_exists($themeDest)) {
         @unlink($themeDest);
     }
     require_once PEAR_PATH . 'File/Archive.php';
     $reader = File_Archive::read($themeSrc, $theme);
     $innerWriter = File_Archive::toFiles();
     $writer = File_Archive::toArchive($themeDest, $innerWriter);
     $res = File_Archive::extract($reader, $writer);
     if (PEAR::isError($res)) {
         return new Jaws_Error(_t('TMS_ERROR_COULD_NOT_PACK_THEME'));
     }
     Jaws_Utils::chmod($themeDest);
     if ($copy_example_to_repository) {
         //Copy image to repository/images
         if (file_exists($srcDir . '/example.png')) {
             @copy($srcDir . '/example.png', JAWS_DATA . "themes/repository/Resources/images/{$theme}.png");
             Jaws_Utils::chmod(JAWS_DATA . 'themes/repository/Resources/images/' . $theme . '.png');
         }
     }
     return $themeDest;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:47,代码来源:Themes.php

示例3: Get

 /**
  *
  */
 function Get($email, $name)
 {
     $ap_dir = JAWS_DATA . 'cache' . DIRECTORY_SEPARATOR . 'addressprotector';
     if (file_exists($ap_dir . DIRECTORY_SEPARATOR . md5($email . $name))) {
         $contents = file_get_contents($ap_dir . DIRECTORY_SEPARATOR . md5($email . $name));
         $contents = '<a href="http://address-protector.com/' . $contents . '">' . $name . '</a>';
         return $contents;
     }
     Jaws_Utils::mkdir($ap_dir);
     if (!is_dir($ap_dir) || !Jaws_Utils::is_writable($ap_dir) || !(bool) ini_get('allow_url_fopen')) {
         $contents = str_replace(array('@', '.'), array('(at)', 'dot'), $email);
         return $contents;
     }
     $url = "http://address-protector.com/?mode=textencrypt&name=<name>&email=<email>";
     $url = str_replace('<name>', urlencode($name), $url);
     $url = str_replace('<email>', $email, $url);
     $contents = $this->getURL($url);
     if (empty($contents)) {
         $contents = str_replace(array('@', '.'), array('(at)', 'dot'), $email);
     }
     if (substr($contents, -1, 1) == "\n") {
         $contents = substr($contents, 0, -1);
     }
     file_put_contents($ap_dir . DIRECTORY_SEPARATOR . md5($email . $name), $contents);
     $contents = '<a href="http://address-protector.com/' . $contents . '">' . $name . '</a>';
     return $contents;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:30,代码来源:AddressProtector.php

示例4: Install

 /**
  * Installs the gadget
  *
  * @access  public
  * @return  mixed   True on successful installation, Jaws_Error otherwise
  */
 function Install()
 {
     if (!Jaws_Utils::is_writable(JAWS_DATA)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', JAWS_DATA));
     }
     $theme_dir = JAWS_DATA . 'themes' . DIRECTORY_SEPARATOR;
     if (!Jaws_Utils::mkdir($theme_dir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $theme_dir));
     }
     //Ok, maybe user has data/themes dir but is not writable, Tms requires that dir to be writable
     if (!Jaws_Utils::is_writable(JAWS_DATA . 'themes')) {
         return new Jaws_Error(_t('TMS_ERROR_DESTINATION_THEMES_NOT_WRITABLE'));
     }
     return true;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:21,代码来源:Installer.php

示例5: Upgrade

 /**
  * Upgrades the gadget
  *
  * @access  public
  * @param   string  $old    Current version (in registry)
  * @param   string  $new    New version (in the $gadgetInfo file)
  * @return  mixed   True on Success or Jaws_Error on Failure
  */
 function Upgrade($old, $new)
 {
     if (!Jaws_Utils::is_writable(JAWS_DATA)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', JAWS_DATA));
     }
     $new_dir = JAWS_DATA . 'languages' . DIRECTORY_SEPARATOR;
     if (!Jaws_Utils::mkdir($new_dir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir));
     }
     // Registry keys
     $this->gadget->registry->delete('use_data_lang');
     $this->gadget->registry->insert('update_default_lang', 'false');
     // ACL keys
     $this->gadget->acl->insert('ModifyLanguageProperties');
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:24,代码来源:Installer.php

示例6: MakeCategoryRSS

 /**
  * Create RSS of a given category
  *
  * @access  public
  * @param   int     $categoryId     Category ID
  * @param   string  $catAtom
  * @param   bool    $writeToDisk    Flag that determinates if Atom file should be written to disk
  * @return  mixed   Returns the RSS(string) if it was required, or Jaws_Error on error
  */
 function MakeCategoryRSS($categoryId, $catAtom = null, $writeToDisk = false)
 {
     if (empty($catAtom)) {
         $catAtom = $this->GetCategoryAtomStruct($categoryId, 'rss');
         if (Jaws_Error::IsError($catAtom)) {
             return $catAtom;
         }
     }
     if ($writeToDisk) {
         if (!Jaws_Utils::is_writable(JAWS_DATA . 'xml')) {
             return new Jaws_Error(_t('BLOG_ERROR_WRITING_CATEGORY_ATOMFILE'));
         }
         $filename = basename($catAtom->Link->HRef);
         $filename = substr($filename, 0, strrpos($filename, '.')) . '.rss';
         $catAtom->SetLink($GLOBALS['app']->getDataURL('xml/' . $filename, false));
         ///FIXME we need to do more error checking over here
         @file_put_contents(JAWS_DATA . 'xml/' . $filename, $catAtom->ToRSS2());
         Jaws_Utils::chmod(JAWS_DATA . 'xml/' . $filename);
     }
     return $catAtom->ToRSS2();
 }
开发者ID:juniortux,项目名称:jaws,代码行数:30,代码来源:Feeds.php

示例7: _check_path

 /**
  * Checks if a path(s) exists
  *
  * @access  private
  * @param   string   $paths         Path(s) to check
  * @param   string   $properties    Properties to use when checking the path
  * @return  boolean  If properties  match the given path(s) we return true, otherwise false
  */
 function _check_path($paths, $properties)
 {
     $paths = !is_array($paths) ? array($paths) : $paths;
     foreach ($paths as $path) {
         $path = JAWS_PATH . $path;
         if ($properties == 'rw') {
             if (!is_readable($path) || !Jaws_Utils::is_writable($path)) {
                 return false;
             }
         } else {
             if ($properties == 'r') {
                 if (!is_readable($path) || !is_dir($path)) {
                     return false;
                 }
             } else {
                 if (!is_dir($path)) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:31,代码来源:Requirements.php

示例8: Run

 /**
  * Does any actions required to finish the stage, such as DB queries.
  *
  * @access  public
  * @return  bool|Jaws_Error  Either true on success, or a Jaws_Error
  *                          containing the reason for failure.
  */
 function Run()
 {
     //config string
     $configString = $this->BuildConfig();
     $configMD5 = md5($configString);
     $existsConfig = @file_get_contents(JAWS_PATH . 'config/JawsConfig.php');
     $existsMD5 = md5($existsConfig);
     if ($configMD5 !== $existsMD5) {
         if (!Jaws_Utils::is_writable(JAWS_PATH . 'config/')) {
             return Jaws_Error::raiseError(_t('UPGRADE_CONFIG_RESPONSE_MAKE_CONFIG', 'JawsConfig.php'), __FUNCTION__, JAWS_ERROR_WARNING);
         }
         // create/overwrite a new one if the dir is writeable
         $result = @file_put_contents(JAWS_PATH . 'config/JawsConfig.php', $configString);
         if ($result === false) {
             return Jaws_Error::raiseError(_t('UPGRADE_CONFIG_RESPONSE_WRITE_FAILED'), __FUNCTION__, JAWS_ERROR_WARNING);
         }
     }
     // Connect to database
     require_once JAWS_PATH . 'include/Jaws/DB.php';
     $objDatabase = Jaws_DB::getInstance('default', $_SESSION['upgrade']['Database']);
     if (Jaws_Error::IsError($objDatabase)) {
         _log(JAWS_LOG_DEBUG, "There was a problem connecting to the database, please check the details and try again");
         return new Jaws_Error(_t('UPGRADE_DB_RESPONSE_CONNECT_FAILED'), 0, JAWS_ERROR_WARNING);
     }
     // Create application
     include_once JAWS_PATH . 'include/Jaws.php';
     $GLOBALS['app'] = jaws();
     $GLOBALS['app']->Registry->Init();
     _log(JAWS_LOG_DEBUG, "Setting " . JAWS_VERSION . " as the current installed version");
     $GLOBALS['app']->Registry->update('version', JAWS_VERSION);
     //remove cache directory
     $path = JAWS_DATA . 'cache';
     if (!Jaws_Utils::delete($path)) {
         _log(JAWS_LOG_DEBUG, "Can't delete {$path}");
     }
     _log(JAWS_LOG_DEBUG, "Configuration file has been created/updated");
     return true;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:45,代码来源:WriteConfig.php

示例9: Run

 /**
  * Does any actions required to finish the stage, such as DB queries.
  *
  * @access  public
  * @return  bool|Jaws_Error  Either true on success, or a Jaws_Error
  *                          containing the reason for failure.
  */
 function Run()
 {
     //config string
     $configString = $this->BuildConfig();
     // following what the web page says (choice 1) and assume that the user has created it already
     if (file_exists(JAWS_PATH . 'config/JawsConfig.php')) {
         $configMD5 = md5($configString);
         $existsConfig = file_get_contents(JAWS_PATH . 'config/JawsConfig.php');
         $existsMD5 = md5($existsConfig);
         if ($configMD5 == $existsMD5) {
             _log(JAWS_LOG_DEBUG, "Previous and new configuration files have the same content, everything is ok");
             return true;
         }
         _log(JAWS_LOG_DEBUG, "Previous and new configuration files have different content, trying to update content");
     }
     // create a new one if the dir is writeable
     if (Jaws_Utils::is_writable(JAWS_PATH . 'config/')) {
         $result = file_put_contents(JAWS_PATH . 'config/JawsConfig.php', $configString);
         if ($result) {
             _log(JAWS_LOG_DEBUG, "Configuration file has been created/updated");
             return true;
         }
         _log(JAWS_LOG_DEBUG, "Configuration file couldn't be created/updated");
         return new Jaws_Error(_t('INSTALL_CONFIG_RESPONSE_WRITE_FAILED'), 0, JAWS_ERROR_ERROR);
     }
     return new Jaws_Error(_t('INSTALL_CONFIG_RESPONSE_MAKE_CONFIG', 'JawsConfig.php'), 0, JAWS_ERROR_WARNING);
 }
开发者ID:juniortux,项目名称:jaws,代码行数:34,代码来源:WriteConfig.php

示例10: NewEntry

 /**
  * Add a new entry
  *
  * @access  public
  * @param   string  $user             User who is adding the photo
  * @param   array   $files            info like original name, tmp name and size
  * @param   string  $title            Title of the image
  * @param   string  $description      Description of the image
  * @param   bool    $fromControlPanel Is it called from ControlPanel?
  * @param   array   $album            Array containing the required info about the album
  * @return  mixed   Returns the ID of the new entry and Jaws_Error on error
  */
 function NewEntry($user, $files, $title, $description, $fromControlPanel = true, $album)
 {
     // check if it's really a uploaded file.
     /*if (is_uploaded_file($files['tmp_name'])) {
           $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
           return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
       }*/
     if (!preg_match("/\\.png\$|\\.jpg\$|\\.jpeg\$|\\.gif\$/i", $files['name'])) {
         $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO_EXT'), RESPONSE_ERROR);
         return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO_EXT'));
     }
     // Create directories
     $uploaddir = JAWS_DATA . 'phoo/' . date('Y_m_d') . '/';
     if (!is_dir($uploaddir)) {
         if (!Jaws_Utils::is_writable(JAWS_DATA . 'phoo/')) {
             $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
             return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
         }
         $new_dirs = array();
         $new_dirs[] = $uploaddir;
         $new_dirs[] = $uploaddir . 'thumb';
         $new_dirs[] = $uploaddir . 'medium';
         foreach ($new_dirs as $new_dir) {
             if (!Jaws_Utils::mkdir($new_dir)) {
                 $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'), RESPONSE_ERROR);
                 return new Jaws_Error(_t('PHOO_ERROR_CANT_UPLOAD_PHOTO'));
             }
         }
     }
     $filename = $files['name'];
     if (file_exists($uploaddir . $files['name'])) {
         $filename = time() . '_' . $files['name'];
     }
     $res = Jaws_Utils::UploadFiles($files, $uploaddir, 'jpg,gif,png,jpeg', false, !$fromControlPanel);
     if (Jaws_Error::IsError($res)) {
         $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
         return new Jaws_Error($res->getMessage());
     } elseif (empty($res)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_UPLOAD_4'), RESPONSE_ERROR);
         return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD_4'));
     }
     $filename = $res[0][0]['host_filename'];
     $uploadfile = $uploaddir . $filename;
     // Resize Image
     include_once JAWS_PATH . 'include/Jaws/Image.php';
     $objImage = Jaws_Image::factory();
     if (Jaws_Error::IsError($objImage)) {
         return Jaws_Error::raiseError($objImage->getMessage());
     }
     $thumbSize = explode('x', $this->gadget->registry->fetch('thumbsize'));
     $mediumSize = explode('x', $this->gadget->registry->fetch('mediumsize'));
     $objImage->load($uploadfile);
     $objImage->resize($thumbSize[0], $thumbSize[1]);
     $res = $objImage->save($this->GetThumbPath($uploadfile));
     $objImage->free();
     if (Jaws_Error::IsError($res)) {
         // Return an error if image can't be resized
         $GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_RESIZE_TO_THUMB'), RESPONSE_ERROR);
         return new Jaws_Error($res->getMessage());
     }
     $objImage->load($uploadfile);
     $objImage->resize($mediumSize[0], $mediumSize[1]);
     $res = $objImage->save($this->GetMediumPath($uploadfile));
     $objImage->free();
     if (Jaws_Error::IsError($res)) {
         // Return an error if image can't be resized
         $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
         return new Jaws_Error(_t('PHOO_ERROR_CANT_RESIZE_TO_MEDIUM'));
     }
     $data = array();
     $data['user_id'] = $user;
     $data['filename'] = date('Y_m_d') . '/' . $filename;
     $data['title'] = $title;
     $data['description'] = $description;
     if ($this->gadget->registry->fetch('allow_comments') === 'true' && $album['allow_comments']) {
         $data['allow_comments'] = true;
     } else {
         $data['allow_comments'] = false;
     }
     if ($this->gadget->registry->fetch('published') === 'true' && $this->gadget->GetPermission('ManageAlbums')) {
         $data['published'] = true;
     } else {
         $data['published'] = false;
     }
     $jDate = Jaws_Date::getInstance();
     $createtime = Jaws_DB::getInstance()->date();
     if (function_exists('exif_read_data') && preg_match("/\\.jpg\$|\\.jpeg\$/i", $files['name']) && ($exifData = @exif_read_data($uploadfile, 1, true)) && !empty($exifData['IFD0']['DateTime']) && $jDate->ValidDBDate($exifData['IFD0']['DateTime'])) {
         $aux = explode(' ', $exifData['IFD0']['DateTime']);
//.........这里部分代码省略.........
开发者ID:Dulciane,项目名称:jaws,代码行数:101,代码来源:Photos.php

示例11: ExtractFiles

 /**
  * Extract archive Files
  *
  * @access  public
  * @param   array   $files        $_FILES array
  * @param   string  $dest         Destination directory(include end directory separator)
  * @param   bool    $extractToDir Create separate directory for extracted files
  * @param   bool    $overwrite    Overwrite directory if exist
  * @param   int     $max_size     Max size of file
  * @return  bool    Returns TRUE on success or FALSE on failure
  */
 static function ExtractFiles($files, $dest, $extractToDir = true, $overwrite = true, $max_size = null)
 {
     if (empty($files) || !is_array($files)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD'), __FUNCTION__);
     }
     if (isset($files['name'])) {
         $files = array($files);
     }
     require_once PEAR_PATH . 'File/Archive.php';
     foreach ($files as $key => $file) {
         if (isset($file['error']) && !empty($file['error']) || !isset($file['name'])) {
             return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD_' . $file['error']), __FUNCTION__);
         }
         if (empty($file['tmp_name'])) {
             continue;
         }
         $ext = strrchr($file['name'], '.');
         $filename = substr($file['name'], 0, -strlen($ext));
         if (false !== stristr($filename, '.tar')) {
             $filename = substr($filename, 0, strrpos($filename, '.'));
             switch ($ext) {
                 case '.gz':
                     $ext = '.tgz';
                     break;
                 case '.bz2':
                 case '.bzip2':
                     $ext = '.tbz';
                     break;
                 default:
                     $ext = '.tar' . $ext;
             }
         }
         $ext = strtolower(substr($ext, 1));
         if (!File_Archive::isKnownExtension($ext)) {
             return new Jaws_Error(_t('GLOBAL_ERROR_UPLOAD_INVALID_FORMAT', $file['name']), __FUNCTION__);
         }
         if ($extractToDir) {
             $dest = $dest . $filename;
         }
         if ($extractToDir && !Jaws_Utils::mkdir($dest)) {
             return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $dest), __FUNCTION__);
         }
         if (!Jaws_Utils::is_writable($dest)) {
             return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', $dest), __FUNCTION__);
         }
         $archive = File_Archive::readArchive($ext, $file['tmp_name']);
         if (PEAR::isError($archive)) {
             return new Jaws_Error($archive->getMessage(), __FUNCTION__);
         }
         $writer = File_Archive::_convertToWriter($dest);
         $result = $archive->extract($writer);
         if (PEAR::isError($result)) {
             return new Jaws_Error($result->getMessage(), __FUNCTION__);
         }
         //@unlink($file['tmp_name']);
     }
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:69,代码来源:Utils.php

示例12: SetLangData


//.........这里部分代码省略.........
                 $orig_file = JAWS_PATH . "upgrade/Resources/translates.ini";
             } else {
                 $orig_file = JAWS_PATH . "languages/{$langTo}/Upgrade.ini";
             }
             $data_file = JAWS_DATA . "languages/{$langTo}/Upgrade.ini";
             break;
         default:
             if ($langTo == 'en') {
                 $orig_file = JAWS_PATH . "include/Jaws/Resources/translates.ini";
             } else {
                 $orig_file = JAWS_PATH . "languages/{$langTo}/Global.ini";
             }
             $data_file = JAWS_DATA . "languages/{$langTo}/Global.ini";
     }
     $update_default_lang = $this->gadget->registry->fetch('update_default_lang') == 'true';
     $strings = array();
     if (file_exists($orig_file)) {
         $strings = parse_ini_file($orig_file, false, INI_SCANNER_RAW);
     }
     // user translation
     $tpl = $this->gadget->template->loadAdmin('FileTemplate.html');
     $tpl->SetBlock('template');
     $tpl->SetVariable('project', $module_name);
     $tpl->SetVariable('language', strtoupper($langTo));
     // orig translation
     $tpl2 = $this->gadget->template->loadAdmin('FileTemplate.html');
     $tpl2->SetBlock('template');
     $tpl2->SetVariable('project', $module_name);
     $tpl2->SetVariable('language', strtoupper($langTo));
     // Meta
     foreach ($data['meta'] as $k => $v) {
         // user translation
         $tpl->SetBlock('template/meta');
         $tpl->SetVariable('key', $k);
         $tpl->SetVariable('value', $v);
         $tpl->ParseBlock('template/meta');
         // orig translation
         $tpl2->SetBlock('template/meta');
         $tpl2->SetVariable('key', $k);
         $tpl2->SetVariable('value', $v);
         $tpl2->ParseBlock('template/meta');
     }
     // Strings
     $change_detected = false;
     foreach ($data['strings'] as $k => $v) {
         if ($v == '') {
             continue;
         } elseif ($v === $this->_EMPTY_STRING) {
             $v = '';
         }
         $v = preg_replace("\$\r\n|\n\$", '\\n', $v);
         $changed = !isset($strings[$k]) || $strings[$k] !== $v;
         if ($changed) {
             $change_detected = true;
             $tpl->SetBlock('template/string');
             $tpl->SetVariable('key', $k);
             $tpl->SetVariable('value', $v);
             $tpl->ParseBlock('template/string');
         }
         // orig translation
         $tpl2->SetBlock('template/string');
         $tpl2->SetVariable('key', $k);
         $tpl2->SetVariable('value', $v);
         $tpl2->ParseBlock('template/string');
     }
     $tpl->ParseBlock('template');
     $tpl2->ParseBlock('template');
     // update original translation
     if ($update_default_lang) {
         // update default language translation,
         // so we can delete customized language's file
         if (Jaws_Utils::file_put_contents($orig_file, $tpl2->Get())) {
             $change_detected = false;
         }
     }
     // Writable
     if (file_exists($data_file)) {
         $writeable = Jaws_Utils::is_writable($data_file);
     } else {
         Jaws_Utils::mkdir(dirname($data_file), 3);
         $writeable = Jaws_Utils::is_writable(dirname($data_file));
     }
     if (!$writeable) {
         $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_NOT_PERMISSION'), RESPONSE_ERROR);
         return false;
     }
     if ($change_detected) {
         if (Jaws_Utils::file_put_contents($data_file, $tpl->Get())) {
             $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_UPDATED', $module), RESPONSE_NOTICE);
             return true;
         } else {
             $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_NOT_UPDATED', $module), RESPONSE_ERROR);
             return false;
         }
     } else {
         Jaws_Utils::Delete($data_file);
         $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_UPDATED', $module), RESPONSE_NOTICE);
         return true;
     }
 }
开发者ID:juniortux,项目名称:jaws,代码行数:101,代码来源:Languages.php

示例13: DisplayFeeds

 /**
  * Displays titles of the feed sites
  *
  * @access  public
  * @param   int     $id     Feed site ID
  * @return  string  XHTML content with all titles and links of feed sites
  */
 function DisplayFeeds($id = 0)
 {
     if (empty($id)) {
         $id = $this->gadget->registry->fetch('default_feed');
     }
     $model = $this->gadget->model->load('Feed');
     $site = $model->GetFeed($id);
     if (Jaws_Error::IsError($site) || empty($site) || $site['visible'] == 0) {
         return false;
     }
     $tpl = $this->gadget->template->load('FeedReader.html');
     $tpl->SetBlock('feedreader');
     require_once JAWS_PATH . 'gadgets/FeedReader/include/XML_Feed.php';
     $parser = new XML_Feed();
     $parser->cache_time = $site['cache_time'];
     $options = array();
     $timeout = (int) $this->gadget->registry->fetch('connection_timeout', 'Settings');
     $options['timeout'] = $timeout;
     if ($this->gadget->registry->fetch('proxy_enabled', 'Settings') == 'true') {
         if ($this->gadget->registry->fetch('proxy_auth', 'Settings') == 'true') {
             $options['proxy_user'] = $this->gadget->registry->fetch('proxy_user', 'Settings');
             $options['proxy_pass'] = $this->gadget->registry->fetch('proxy_pass', 'Settings');
         }
         $options['proxy_host'] = $this->gadget->registry->fetch('proxy_host', 'Settings');
         $options['proxy_port'] = $this->gadget->registry->fetch('proxy_port', 'Settings');
     }
     $parser->setParams($options);
     if (Jaws_Utils::is_writable(JAWS_DATA . 'feedcache')) {
         $parser->cache_dir = JAWS_DATA . 'feedcache';
     }
     $res = $parser->fetch(Jaws_XSS::defilter($site['url']));
     if (PEAR::isError($res)) {
         $GLOBALS['log']->Log(JAWS_LOG_ERROR, '[' . $this->gadget->title . ']: ', _t('FEEDREADER_ERROR_CANT_FETCH', Jaws_XSS::refilter($site['url'])), '');
     }
     if (!isset($parser->feed)) {
         return false;
     }
     $block = $site['view_type'] == 0 ? 'simple' : 'marquee';
     $tpl->SetBlock("feedreader/{$block}");
     $tpl->SetVariable('title', _t('FEEDREADER_ACTION_TITLE'));
     switch ($site['title_view']) {
         case 1:
             $tpl->SetVariable('feed_title', Jaws_XSS::refilter($parser->feed['channel']['title']));
             $tpl->SetVariable('feed_link', Jaws_XSS::refilter(isset($parser->feed['channel']['link']) ? $parser->feed['channel']['link'] : ''));
             break;
         case 2:
             $tpl->SetVariable('feed_title', Jaws_XSS::refilter($site['title']));
             $tpl->SetVariable('feed_link', Jaws_XSS::refilter(isset($parser->feed['channel']['link']) ? $parser->feed['channel']['link'] : ''));
             break;
         default:
     }
     $tpl->SetVariable('marquee_direction', $site['view_type'] == 2 ? 'down' : ($site['view_type'] == 3 ? 'left' : ($site['view_type'] == 4 ? 'right' : 'up')));
     if (isset($parser->feed['items'])) {
         foreach ($parser->feed['items'] as $index => $item) {
             $tpl->SetBlock("feedreader/{$block}/item");
             $tpl->SetVariable('title', Jaws_XSS::refilter($item['title']));
             $tpl->SetVariable('href', isset($item['link']) ? Jaws_XSS::refilter($item['link']) : '');
             $tpl->ParseBlock("feedreader/{$block}/item");
             if ($site['count_entry'] > 0 && $site['count_entry'] <= $index + 1) {
                 break;
             }
         }
     }
     $tpl->ParseBlock("feedreader/{$block}");
     $tpl->ParseBlock('feedreader');
     return $tpl->Get();
 }
开发者ID:juniortux,项目名称:jaws,代码行数:74,代码来源:Feed.php


注:本文中的Jaws_Utils::is_writable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。