/** * @param string $type * @param string $path * @return array */ public static function objects($type, $path = null) { $type = strtolower($type); App::import('Core', 'GummFolder'); switch ($type) { case 'controller': if (!$path) { $path = GUMM_CONTROLLERS; } $Folder = new GummFolder($path); } $objects = array(); if (isset($Folder)) { $list = $Folder->read(); foreach ($list[1] as $objectFile) { $objectName = str_replace('_' . $type, '', $objectFile); $objectName = str_replace('.php', '', $objectName); $objectName = Inflector::camelize($objectName); $objectClass = $type == 'model' ? $objectName : $objectName . ucwords($type); // App::import($type, $objectName); $objects[$objectName] = $objectClass; } } return $objects; }
/** * @param string $id * @return void */ public function admin_edit($id = null) { if (!$id) { $id = $this->RequestHandler->getNamed('id'); } if (!$id) { $id = uniqid(); } $skin = $this->Skin->findById($id); if ($this->data) { if (!$this->validates()) { die(__('Security check failed.', 'gummfw')); } $this->Skin->save($this->data); if ($this->RequestHandler->isAjax()) { $skins = $this->Skin->find('list'); $activeSkinId = null; if ($this->Skin->lastModifiedId && isset($skins[$this->Skin->lastModifiedId])) { $activeSkinId = $this->Skin->lastModifiedId; } $this->set(compact('skins', 'activeSkinId')); $this->render('admin_index'); } } App::import('Core', 'GummFolder'); $Folder = new GummFolder(GUMM_ASSETS . 'css' . DS . 'skins'); if ($cssFilesAvailable = end($Folder->read(false))) { $cssFilesAvailable = array_combine($cssFilesAvailable, $cssFilesAvailable); } array_unshift($cssFilesAvailable, 'none'); $this->set(compact('id', 'skin', 'cssFilesAvailable')); }
/** * @param string * @return array */ private function getPatternFromPath($path, $type = null) { if (!class_exists('GummFolder')) { App::import('Core', 'GummFolder'); } $pi = pathinfo($path); $patternName = $pi['filename']; // if (is_file($path)) { $pattern = array_merge($this->_schema, array('id' => Inflector::slug($patternName, '-'), 'type' => $type, 'name' => $patternName, 'url' => GUMM_THEME_URL . '/images/textures/' . $type . '/' . $patternName, 'schemes' => array())); if (is_dir($path)) { $Folder = new GummFolder($path); $contents = $Folder->read(true, false, true); $defaultPatternUrl = $pattern['url']; if ($contents[0]) { foreach ($contents[0] as $patternSchemeFullPath) { $patternSchemeName = basename($patternSchemeFullPath); $Folder->cd($patternSchemeFullPath); $schemeContents = $Folder->read(true, false, true); $pattern['schemes'][$patternSchemeName] = array('weights' => array()); foreach ($schemeContents[1] as $schemeWeightFullPath) { $pi = pathinfo($schemeWeightFullPath); if ($pi['extension'] != 'png') { continue; } $weight = 100; if (preg_match("'.*\\-([0-9]+)'", $pi['basename'], $weight)) { $weight = (int) $weight[1]; } $pattern['schemes'][$patternSchemeName]['weights'][$weight] = array('value' => $weight, 'url' => $pattern['url'] . '/' . $patternSchemeName . '/' . $pi['basename']); if ($patternSchemeName == 'dark' && (int) $weight == 100) { $defaultPatternUrl = $pattern['schemes'][$patternSchemeName]['weights'][$weight]['url']; } } } $pattern['url'] = $defaultPatternUrl; } elseif ($contents[1]) { $pattern['url'] .= basename($contents[1][0]); } } return $pattern; }