Esempio n. 1
0
 /**
  * Method to get the base upload path for a project
  *
  * @param     int       $project     Optional project id
  *
  * @return    string    $basepath    The upload directory
  */
 public static function getBasePath($project = null)
 {
     static $cache = array();
     $project = (int) $project;
     // Check the cache
     if (isset($cache[$project])) {
         return $cache[$project];
     }
     $params = JComponentHelper::GetParams('com_pfrepo');
     $dest = $params->get('repo_basepath', '/media/com_projectfork/repo/');
     $base = JPATH_SITE . '/';
     $fchar = substr($dest, 0, 1);
     $lchar = substr($dest, -1, 1);
     if ($fchar == '/' || $fchar == '\\') {
         $dest = substr($dest, 1);
     }
     if ($lchar == '/' || $lchar == '\\') {
         $dest = substr($dest, 0, -1);
     }
     if ($project) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('path')->from('#__pf_repo_dirs')->where('project_id = ' . $project)->where('parent_id = 1');
         $db->setQuery($query);
         $path = $db->loadResult();
         if (empty($path)) {
             $query->clear()->select('alias')->from('#__pf_projects')->where('id = ' . $project);
             $db->setQuery($query);
             $path = $db->loadResult();
         }
         if ($path) {
             $dest .= '/' . $path;
         }
     }
     $cache[$project] = JPath::clean($base . $dest);
     return $cache[$project];
 }
Esempio n. 2
0
 /**
  * Method to get the Projectfork config settings merged into
  * the project settings
  *
  * @param     integer    $id        Optional project id. If not provided, will use the currently active project
  *
  * @return    object     $params    The config settings
  */
 public static function getProjectParams($id = 0)
 {
     static $cache = array();
     $project = $id > 0 ? (int) $id : self::getActiveProjectId();
     if (array_key_exists($project, $cache)) {
         return $cache[$project];
     }
     $params = JComponentHelper::GetParams('com_projectfork');
     // Get the project parameters if they exist
     if ($project) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('attribs')->from('#__pf_projects')->where('id = ' . $db->quote($project));
         $db->setQuery((string) $query);
         $attribs = $db->loadResult();
         if (!empty($attribs)) {
             $registry = new JRegistry();
             $registry->loadString($attribs);
             $params->merge($registry);
         }
     }
     $cache[$project] = $params;
     return $cache[$project];
 }
Esempio n. 3
0
 /**
  * Method to get the base upload path for a design
  *
  * @param     int       $project     Optional project id
  *
  * @return    string    $basepath    The upload directory
  */
 public static function getBasePath($project = NULL)
 {
     jimport('joomla.filesystem.path');
     $params = JComponentHelper::GetParams('com_pfdesigns');
     $base = JPATH_SITE . '/';
     $dest = $params->get('design_basepath', '/images/com_projectfork/designs/');
     $fchar = substr($dest, 0, 1);
     $lchar = substr($dest, -1, 1);
     if ($fchar == '/' || $fchar == '\\') {
         $dest = substr($dest, 1);
     }
     if ($lchar == '/' || $lchar == '\\') {
         $dest = substr($dest, 0, -1);
     }
     if (is_numeric($project)) {
         $dest .= '/project_' . (int) $project;
     }
     $basepath = JPath::clean($base . $dest);
     return $basepath;
 }